diff --git a/Backend/Areas/Admin/Controllers/AccountsController.cs b/Backend/Areas/Admin/Controllers/AccountsController.cs index 27c3387..d644152 100644 --- a/Backend/Areas/Admin/Controllers/AccountsController.cs +++ b/Backend/Areas/Admin/Controllers/AccountsController.cs @@ -19,7 +19,7 @@ public AccountsController() users = new Repository(); roles = new Repository(); } - + public ActionResult Index() { return View(); @@ -55,9 +55,56 @@ public ActionResult GetRole() { return Json(roles.Get(), JsonRequestBehavior.AllowGet); } + [HttpPost] + public ActionResult ChangePassword(AdminChangePasswordViewModels changePasswordViewModel) + { + var errors = new Dictionary(); + var userUpdate = users.Get(changePasswordViewModel.AccountId); + foreach (var k in ModelState.Keys) + foreach (var err in ModelState[k].Errors) + { + var key = Regex.Replace(k, @"(\w+)\.(\w+)", @"$2"); + if (!errors.ContainsKey(key)) + errors.Add(key, err.ErrorMessage); + } + + if (!ModelState.IsValid) + return Json(new + { + data = errors, + statusCode = 400, + message = "Error", + }, JsonRequestBehavior.AllowGet); + + if (!changePasswordViewModel.Password.Equals(changePasswordViewModel.RePassword)) + { + errors.Add("ConfirmPassword", "Your confirm is not the same as your new password!"); + return Json(new + { + data = errors, + statusCode = 400, + message = "Error", + }, JsonRequestBehavior.AllowGet); + } + userUpdate.Password = Utils.HashPassword(changePasswordViewModel.Password); + if (!users.Edit(userUpdate)) + { + return Json(new + { + data = errors, + statusCode = 400, + message = "Error", + }, JsonRequestBehavior.AllowGet); + } + return Json(new + { + statusCode = 200, + message = "Change Password Successfully", + }, JsonRequestBehavior.AllowGet); + } [HttpPost] - public ActionResult Create(Accounts accounts) + public ActionResult Create(AccountViewModel accounts) { var errors = new Dictionary(); var check = true; @@ -99,13 +146,6 @@ public ActionResult Create(Accounts accounts) check = false; errors.Add("Phone", "Your Phone has been used!"); } - - - // if () - // { - // check = false; - // errors.Add("Phone", "Your Phone has been used!"); - // } if (users.CheckDuplicate(x => x.NumberId == accounts.NumberId)) { check = false; @@ -120,7 +160,20 @@ public ActionResult Create(Accounts accounts) if (ModelState.IsValid && check) { - users.Add(accounts); + var account = new Accounts + { + Name = accounts.Name, + Email = accounts.Email, + Password = Utils.HashPassword("123456"), + NumberId = accounts.NumberId, + Phone = accounts.Phone, + AttemptLogin = 0, + RoleId = accounts.RoleId, + Address = accounts.Address, + Birthday = DateTime.Parse(accounts.Birthday), + Status = ((int)AccountStatus.Actived) + }; + users.Add(account); return Json(new { statusCode = 200, @@ -129,12 +182,12 @@ public ActionResult Create(Accounts accounts) } foreach (var k in ModelState.Keys) - foreach (var err in ModelState[k].Errors) - { - var key = Regex.Replace(k, @"(\w+)\.(\w+)", @"$2"); - if (!errors.ContainsKey(key)) - errors.Add(key, err.ErrorMessage); - } + foreach (var err in ModelState[k].Errors) + { + var key = Regex.Replace(k, @"(\w+)\.(\w+)", @"$2"); + if (!errors.ContainsKey(key)) + errors.Add(key, err.ErrorMessage); + } return Json(new { @@ -145,8 +198,9 @@ public ActionResult Create(Accounts accounts) } [HttpPost] - public ActionResult Edit(Accounts accounts) + public ActionResult Edit(AccountViewModel accounts) { + var acc1 = users.Get(accounts.AccountId); var errors = new Dictionary(); var check = true; @@ -177,7 +231,7 @@ public ActionResult Edit(Accounts accounts) } } - if (users.CheckDuplicate(x => x.Email == accounts.Email && x.AccountId != acc1.AccountId) ) + if (users.CheckDuplicate(x => x.Email == accounts.Email && x.AccountId != acc1.AccountId)) { check = false; errors.Add("Email", "Your email has been used!"); @@ -203,17 +257,24 @@ public ActionResult Edit(Accounts accounts) if (ModelState.IsValid && check) { - - acc1.Name = accounts.Name; - acc1.Email = accounts.Email; - acc1.Password = accounts.Password; - acc1.Phone = accounts.Phone; - acc1.Birthday = accounts.Birthday; - acc1.Address = accounts.Address; - acc1.NumberId = accounts.NumberId; - acc1.RoleId = accounts.RoleId; - acc1.Status = accounts.Status; - users.Edit(acc1); + var acc3 = users.Get(accounts.AccountId); + acc3.Name = accounts.Name; + acc3.Email = accounts.Email; + acc3.Phone = accounts.Phone; + acc3.Birthday = DateTime.Parse(accounts.Birthday); + acc3.Address = accounts.Address; + acc3.NumberId = accounts.NumberId; + acc3.RoleId = accounts.RoleId; + acc3.Status = accounts.Status; + if (!users.Edit(acc3)) + { + return Json(new + { + statusCode = 400, + message = "Error", + data = "Error" + }, JsonRequestBehavior.AllowGet); + } return Json(new { @@ -223,12 +284,12 @@ public ActionResult Edit(Accounts accounts) } foreach (var k in ModelState.Keys) - foreach (var err in ModelState[k].Errors) - { - var key = Regex.Replace(k, @"(\w+)\.(\w+)", @"$2"); - if (!errors.ContainsKey(key)) - errors.Add(key, err.ErrorMessage); - } + foreach (var err in ModelState[k].Errors) + { + var key = Regex.Replace(k, @"(\w+)\.(\w+)", @"$2"); + if (!errors.ContainsKey(key)) + errors.Add(key, err.ErrorMessage); + } return Json(new { @@ -237,9 +298,25 @@ public ActionResult Edit(Accounts accounts) data = errors }, JsonRequestBehavior.AllowGet); } - + [HttpPost] public ActionResult Delete(int id) { + using (var _context = new ApplicationDbContext()) + { + var user = _context.Accounts.FirstOrDefault(x => x.AccountId == id); + var bankaccount = _context.BankAccounts.FirstOrDefault(x => x.AccountId == id); + if (bankaccount != null) + { + user.Status = 2; + _context.SaveChanges(); + return Json(new + { + statusCode = 200, + message = "Success" + }, JsonRequestBehavior.AllowGet); + } + } + if (users.Delete(id)) { return Json(new @@ -258,7 +335,7 @@ public ActionResult Delete(int id) public ActionResult ProfileAccount(int id) { - if (((Accounts) Session["user"]) == null) return RedirectToAction("Login", "Home", new {area = ""}); + if (((Accounts)Session["user"]) == null) return RedirectToAction("Login", "Home", new { area = "" }); var x = users.Get(id); if (x == null) { diff --git a/Backend/Areas/Admin/Controllers/BankAccountsController.cs b/Backend/Areas/Admin/Controllers/BankAccountsController.cs index 08d008f..290fe1d 100644 --- a/Backend/Areas/Admin/Controllers/BankAccountsController.cs +++ b/Backend/Areas/Admin/Controllers/BankAccountsController.cs @@ -59,6 +59,15 @@ public ActionResult GetInfoBankAccount(string name) Name = x.Account.Name, Id = x.BankAccountId }); + if (data.FirstOrDefault() == null) + { + return Json(new + { + data, + message = "Error", + statusCode = 400 + }, JsonRequestBehavior.AllowGet); + } return Json(new { data, @@ -106,7 +115,7 @@ public ActionResult Create(BankAccounts bank) var errors = new Dictionary(); var check = true; - if (!int.TryParse(bank.Name, out int i)) + if (!long.TryParse(bank.Name, out long i)) { check = false; errors.Add("NameBank", "Your name must be number"); @@ -196,6 +205,21 @@ public ActionResult Edit(BankAccounts bank) [HttpPost] public ActionResult Delete(int id) { + using (var _context1 = new ApplicationDbContext()) + { + var bankAccount = _context1.BankAccounts.FirstOrDefault(x => x.BankAccountId == id); + var transaction = _context1.TransactionDetails.FirstOrDefault(x => x.BankAccountId == id); + if (transaction != null) + { + bankAccount.Status = 3; + _context1.SaveChanges(); + return Json(new + { + statusCode = 200, + message = "Success" + }, JsonRequestBehavior.AllowGet); + } + } if (bankAccounts.Delete(id)) { return Json(new diff --git a/Backend/Areas/Admin/Controllers/ChequesController.cs b/Backend/Areas/Admin/Controllers/ChequesController.cs index 63d2f72..81e5d85 100644 --- a/Backend/Areas/Admin/Controllers/ChequesController.cs +++ b/Backend/Areas/Admin/Controllers/ChequesController.cs @@ -435,11 +435,8 @@ public ActionResult ChequeExec(ChequesExecViewModel chequeExec) var newNotifications = CreateNotifications(newTransaction); transaction.Commit(); - - // using (var chatHub = new ChatHub()) - // { - // chatHub.SendNotifications(newNotifications); - // } + + ChatHub.Instance().SendNotifications(newNotifications); return Json(new { diff --git a/Backend/Areas/Admin/Views/Accounts/Index.cshtml b/Backend/Areas/Admin/Views/Accounts/Index.cshtml index 33036b1..51998cc 100644 --- a/Backend/Areas/Admin/Views/Accounts/Index.cshtml +++ b/Backend/Areas/Admin/Views/Accounts/Index.cshtml @@ -70,12 +70,6 @@ -
- -
- -
-
@@ -132,7 +126,36 @@
- + @section AdminlteJs{ } @@ -148,7 +171,8 @@ var birthDate = new Date(value); var age = today.getFullYear() - birthDate.getFullYear(); return age >= min; - }, "You are not old enough!"); + }, "You are not old enough!"); + const validator = $("#formData").validate({ rules: { "Name": { @@ -157,9 +181,6 @@ "Email": { required: true }, - "Password": { - required: true - }, "Birthday": { required: true, minAge: 18, @@ -202,7 +223,6 @@ const user = { Name: $("#Name").val(), Email: $("#Email").val(), - Password: $("#Password").val(), Birthday: $("#Birthday").val(), Address: $("#Address").val(), Phone: $("#Phone").val(), @@ -218,13 +238,60 @@ } } }); - + const validator2 = $("#FormPasswordChange").validate({ + rules: { + "NewPassword": { + required: true, + minlength: 6, + }, + "ConfirmPassword": { + required: true, + minlength: 6, + }, + }, + ignore: [], + errorClass: "invalid-feedback animated fadeInUp", + errorElement: "div", + errorPlacement: function (e, a) { + jQuery(a).after(e) + }, + highlight: function (e) { + jQuery(e).closest(".form-group").removeClass("is-invalid").addClass("is-invalid") + }, + success: function (e) { + jQuery(e).closest(".form-group").removeClass("is-invalid").addClass("is-valid") + }, + + submitHandler: function () { + let account = { + AccountId: $("#Id2").val(), + Password: $("#NewPassword").val(), + RePassword: $("#ConfirmPassword").val(), + }; + $.ajax({ + type: "POST", + url: "/Admin/Accounts/ChangePassword", + data: { + changePasswordViewModel: account + }, + success: function (res) { + if (res.statusCode == 200) { + notifySuccess("Success", "Password Change Success"); + $("#PasswordChange").modal("hide"); + } else { + notifyError("Error", "Password Change Error"); + validator2.showErrors(res.data); + } + } + }) + } + }); + function loadStatus(status = null) { $.ajax({ type: "GET", url: "@Url.Action("GetStatus", "Accounts")", success: function (res) { - console.log(res) var html; $.each(res, function (key, value) { html += ""; @@ -258,7 +325,6 @@ $("#Id").val(res.AccountId); $("#Name").val(res.Name); $("#Email").val(res.Email); - $("#Password").val(res.Password); $("#Phone").val(res.Phone); $("#Address").val(res.Address); $("#Birthday").val(res.Birthday); @@ -306,8 +372,9 @@ }, delete: function (id) { $.ajax({ - type: "GET", - url: `/Admin/Accounts/Delete/${id}`, + type: "POST", + url: "@Url.Action("Delete", "Accounts")", + data: {id : id}, success: function (res) { if (res.statusCode === 200) { notifySuccess('Successfully',"Deleted Successfully"); @@ -316,7 +383,7 @@ notifyError('Error',"Deleted Error"); $('#datatables').DataTable().ajax.reload(); } - + } }) } @@ -363,7 +430,7 @@ }else { return ''+data.StatusName+''; } - + }, className: 'align-middle text-center', "searchable": false, @@ -374,6 +441,7 @@ "render": function (data) { let detail = "@Url.Action("ProfileAccount", "Accounts")/"+data.AccountId; return '' @@ -387,7 +455,12 @@ let userId = $(this).data("id"); let a = managerAcc.get(userId); }) - + $(document).on("click", ".btn-changepass", function () { + $("#PasswordChange").modal("show"); + let userId = $(this).data("id"); + $("#Id2").val(userId); + }) + $(document).on("click", ".btn-add", function () { validator.resetForm(); loadRole(0); diff --git a/Backend/Areas/Admin/Views/Accounts/ProfileAccount.cshtml b/Backend/Areas/Admin/Views/Accounts/ProfileAccount.cshtml index d4af41b..351c51d 100644 --- a/Backend/Areas/Admin/Views/Accounts/ProfileAccount.cshtml +++ b/Backend/Areas/Admin/Views/Accounts/ProfileAccount.cshtml @@ -365,7 +365,8 @@ $("#myModal").modal("hide"); $('#tbl_banks').DataTable().ajax.reload(); notifySuccess('Created Successfully',"Created BankAccounts Successfully") - }else { + } else { + validator.showErrors(res.data); } } @@ -382,7 +383,8 @@ $("#myModal").modal("hide"); $('#tbl_banks').DataTable().ajax.reload(); notifySuccess('Updated Successfully',"Updated BankAccounts Successfully"); - }else{ + } else { + notifyError('Created Error', res.data) validator.showErrors(res.data); } } @@ -398,7 +400,7 @@ notifySuccess('Deleted Successfully',"Deleted BankAccounts Successfully"); $('#tbl_banks').DataTable().ajax.reload(); }else { - notifyError('Error',"Deleted BankAccounts Error"); + notifyError('Error', res.data); $('#tbl_banks').DataTable().ajax.reload(); } @@ -411,6 +413,7 @@ url: "/Transactions/Transfers", data: trans, success: function (res) { + console.log(res) if (res.statusCode === 200) { $("#MoneyManagement").modal("hide"); $('#tbl_banks').DataTable().ajax.reload(); diff --git a/Backend/Areas/Admin/Views/BankAccounts/Index.cshtml b/Backend/Areas/Admin/Views/BankAccounts/Index.cshtml index 11f1eb6..9c440ff 100644 --- a/Backend/Areas/Admin/Views/BankAccounts/Index.cshtml +++ b/Backend/Areas/Admin/Views/BankAccounts/Index.cshtml @@ -263,7 +263,8 @@ $("#myModal").modal("hide"); $('#tbl_banks').DataTable().ajax.reload(); notifySuccess('Created Successfully',"Created BankAccounts Successfully") - }else { + } else { + notifyError('Created Error', res.data) validator.showErrors(res.data); } } @@ -280,7 +281,8 @@ $("#myModal").modal("hide"); $('#tbl_banks').DataTable().ajax.reload(); notifySuccess('Updated Successfully',"Updated BankAccounts Successfully"); - }else{ + } else { + notifyError('Created Error', res.data) validator.showErrors(res.data); } } @@ -296,7 +298,7 @@ notifySuccess('Deleted Successfully',"Deleted BankAccounts Successfully"); $('#tbl_banks').DataTable().ajax.reload(); }else { - notifyError('Error',"Deleted BankAccounts Error"); + notifyError('Error',res.data); $('#tbl_banks').DataTable().ajax.reload(); } @@ -313,8 +315,8 @@ $("#MoneyManagement").modal("hide"); $('#tbl_banks').DataTable().ajax.reload(); notifySuccess("Transfers Successfully", res.data); - }else { - notifyError("Transfers Error", res.data.FromId); + } else { + notifyError("Transfers Error", res.data.FormId); } } @@ -337,6 +339,10 @@ "columns": [ { data: 'BankAccountId', + className: 'align-middle', + render: function (data, type, row) { + return `#${row.BankAccountId}`; + }, className: 'align-middle text-center' }, { diff --git a/Backend/Areas/Admin/Views/BankAccounts/ProfileBankAccount.cshtml b/Backend/Areas/Admin/Views/BankAccounts/ProfileBankAccount.cshtml index 4e55b83..83fed06 100644 --- a/Backend/Areas/Admin/Views/BankAccounts/ProfileBankAccount.cshtml +++ b/Backend/Areas/Admin/Views/BankAccounts/ProfileBankAccount.cshtml @@ -162,7 +162,6 @@ { data: { Amount: 'Amount', Type: 'Type', Currency: "Currency" }, render: function (data) { - let fromId = $("#fromId").val(); return (data.Amount) == null ? "" : ((data.Type ? " - " : " + ") + new Intl.NumberFormat('vi-VN', { style: 'currency', currency: data.Currency }).format(data.Amount)); }, className: 'align-middle', @@ -187,7 +186,6 @@ }, ], - dom: 'Bfrtip', dom: 'Bfrtip', buttons: [ { extend: 'excel', className: 'btn btn-primary glyphicon glyphicon-list-alt' }, diff --git a/Backend/Areas/Admin/Views/Cheques/Cheque.cshtml b/Backend/Areas/Admin/Views/Cheques/Cheque.cshtml index 32bc980..68d84de 100644 --- a/Backend/Areas/Admin/Views/Cheques/Cheque.cshtml +++ b/Backend/Areas/Admin/Views/Cheques/Cheque.cshtml @@ -50,6 +50,8 @@ @@ -132,7 +134,7 @@ @section scripts{ - } \ No newline at end of file diff --git a/Backend/Areas/Admin/Views/Currencies/Index.cshtml b/Backend/Areas/Admin/Views/Currencies/Index.cshtml index 6dc6b2c..ec97907 100644 --- a/Backend/Areas/Admin/Views/Currencies/Index.cshtml +++ b/Backend/Areas/Admin/Views/Currencies/Index.cshtml @@ -106,7 +106,7 @@ } } }); - + const currencyManager = { post: function (currency) { $.ajax({ @@ -190,7 +190,10 @@ className: 'align-middle', }, { - data: 'StatusName', + data: { StatusName:'StatusName'}, + render:function(data) { + return '' + data.StatusName + ''; + }, className: 'align-middle', }, { diff --git a/Backend/Areas/Admin/Views/Home/InfoAccount.cshtml b/Backend/Areas/Admin/Views/Home/InfoAccount.cshtml index f187aa1..d9b01e3 100644 --- a/Backend/Areas/Admin/Views/Home/InfoAccount.cshtml +++ b/Backend/Areas/Admin/Views/Home/InfoAccount.cshtml @@ -75,9 +75,9 @@
- +
- +
@@ -154,7 +154,7 @@ required: true, email: true, }, - NumberID: { + NumberId: { required: true, minlength: 9, }, @@ -189,7 +189,7 @@ Email: $("#Email").val(), Phone: $("#Phone").val(), Birthday: $("#Birthday").val(), - NumberID: $("#NumberID").val(), + NumberId: $("#NumberId").val(), Address: $("#Address").val(), } accounts.put(user); @@ -244,7 +244,7 @@ $("#Email").val(response.data.Email); $("#Phone").val(response.data.Phone); $("#Birthday").val(response.data.Birthday); - $("#NumberID").val(response.data.NumberId); + $("#NumberId").val(response.data.NumberId); $("#Address").val(response.data.Address); $("#TextName").html(response.data.Name); $("#TextEmail").html(response.data.Email); diff --git a/Backend/Areas/Admin/Views/Roles/Index.cshtml b/Backend/Areas/Admin/Views/Roles/Index.cshtml index 9bfbc27..89cbd14 100644 --- a/Backend/Areas/Admin/Views/Roles/Index.cshtml +++ b/Backend/Areas/Admin/Views/Roles/Index.cshtml @@ -68,7 +68,10 @@ className: 'align-middle', }, { - data: 'StatusName', + data: { StatusName: 'StatusName'}, + render: function (data) { + return '' + data.StatusName + ''; + }, className: 'align-middle', }, ] diff --git a/Backend/Controllers/TransactionsController.cs b/Backend/Controllers/TransactionsController.cs index 732b4a3..0a6ec92 100644 --- a/Backend/Controllers/TransactionsController.cs +++ b/Backend/Controllers/TransactionsController.cs @@ -51,61 +51,6 @@ public ActionResult Index() return View(); } - //private JsonResult TransfersQueue() - //{ - // lock (Lock) - // { - // var errors = new Dictionary(); - - // var bankDequeue = bankQueue.Dequeue(); - // do - // { - // var receiverStatus = receiverAccount.Status; - // var sessionUsers = (Accounts)Session["user"]; - // if (sessionUsers.RoleId == 1) - // { - - - // if (receiverStatus != 0) - // { - // errors.Add("ToId", "Receipt download has not been activated"); - // return Json(new - // { - // data = errors, - // message = "Error", - // statusCode = 404 - // }, JsonRequestBehavior.AllowGet); - // } - - // receiverAccount.Balance += bankDequeue.Amount; - // if (bankAccounts.Edit(receiverAccount) != true) - // return Json(new - // { - // data = "Error adding target account money", - // message = "Error", - // statusCode = 404 - // }, JsonRequestBehavior.AllowGet); - // bankDequeue.Status = 1; - // bankDequeue.CreatedAt = DateTime.Now; - // bankDequeue.UpdatedAt = DateTime.Now; - // bankDequeue.BalancedTo = receiverAccount.Balance; - - - // return Json(new - // { - // data = "Transfer failed", - // message = "Error", - // statusCode = 404 - // }); - // } - - - // } while (bankQueue.Count != 0); - - - // } - //} - public ActionResult GetData(int fromId, DateTime? startDate, DateTime? endDate) { var data = transactionDetails.Get(x => x.BankAccountId == fromId); @@ -161,6 +106,11 @@ private JsonResult HandlerTransfer() sourceBankAccount = _context.BankAccounts.Where(x => x.AccountId == sessionUsers.AccountId && x.CurrencyId == currenReceiverBankAccount).FirstOrDefault(); + if (tran.ToId == sourceBankAccount.Name) + { + goto PlusMoney; + } + var minusError1 = MinusMoney(tran, sourceBankAccount, errors); if (minusError1 != null) { @@ -185,7 +135,9 @@ private JsonResult HandlerTransfer() // Plus money PlusMoney: + receiverBankAccount = _context.BankAccounts.FirstOrDefault(x => x.Name == tran.ToId); + var plusError = PlusMoney(tran, receiverBankAccount, errors); if (plusError != null) { @@ -199,7 +151,9 @@ private JsonResult HandlerTransfer() var newNotifications = CreateNotifications(newTransaction); transaction.Commit(); - + + ChatHub.Instance().SendNotifications(newNotifications); + return Json(new { data = "Successful transfer", @@ -207,7 +161,7 @@ private JsonResult HandlerTransfer() statusCode = 200 }); } - catch (Exception) + catch (Exception ex) { transaction.Rollback(); } @@ -247,18 +201,10 @@ private JsonResult CheckTransactionRequestModels(TransactionRequestModels tran, statusCode = 404 }, JsonRequestBehavior.AllowGet); } + var sourceBankAccount = bankAccounts.Get(x => x.Name == tran.FromId).FirstOrDefault(); var receiverBankAccount = bankAccounts.Get(x => x.Name == tran.ToId).FirstOrDefault(); - if (tran.FromId.Contains(tran.ToId)) - { - errors.Add("ToId", "The number of the receiving account and the sending account is the same"); - return Json(new - { - data = errors, - message = "Error", - statusCode = 404 - }, JsonRequestBehavior.AllowGet); - } + if (tran.Amount <= 0) { @@ -305,6 +251,17 @@ private JsonResult CheckTransactionRequestModels(TransactionRequestModels tran, }, JsonRequestBehavior.AllowGet); } + if (sourceBankAccount.BankAccountId == receiverBankAccount.BankAccountId) + { + errors.Add("ToId", "The number of the receiving account and the sending account is the same"); + return Json(new + { + data = errors, + message = "Error", + statusCode = 404 + }, JsonRequestBehavior.AllowGet); + } + return null; } diff --git a/Backend/Hubs/ChatHub.cs b/Backend/Hubs/ChatHub.cs index c0fada9..b87424f 100644 --- a/Backend/Hubs/ChatHub.cs +++ b/Backend/Hubs/ChatHub.cs @@ -191,16 +191,20 @@ public void SendNotifications(List notifications) { try { + var context = GlobalHost.ConnectionManager.GetHubContext(); + notifications.ForEach(x => { - var pkObject = transactionDetailRepo - .Get().FirstOrDefault(y => y.TransactionDetailId == x.PkId); + var pkObject = transactionDetailRepo.Get() + .FirstOrDefault(y => y.TransactionDetailId == x.PkId); - Clients.Group("user-" + x.AccountId) + context.Clients.Group("user-" + x.AccountId) .newNotification(new NotificationViewModel(x, pkObject)); + // await context.Clients.Group("user-" + x.AccountId) + // .historyNotifications(GetNotificationsHistory(GetIntegerAccountId())); }); } - catch (Exception) + catch (Exception ex) { Clients.Caller.onError("Notification can't not send!"); } diff --git a/Backend/Views/Home/InfoAccount.cshtml b/Backend/Views/Home/InfoAccount.cshtml index f232cf7..886ff62 100644 --- a/Backend/Views/Home/InfoAccount.cshtml +++ b/Backend/Views/Home/InfoAccount.cshtml @@ -89,9 +89,9 @@
- +
- +
@@ -172,7 +172,7 @@ required: true, email: true, }, - NumberID: { + NumberId: { required: true, minlength: 9, }, @@ -207,7 +207,7 @@ Email: $("#Email").val(), Phone: $("#Phone").val(), Birthday: $("#Birthday").val(), - NumberID: $("#NumberID").val(), + NumberId: $("#NumberId").val(), Address: $("#Address").val(), } accounts.put(user); @@ -262,7 +262,7 @@ $("#Email").val(response.data.Email); $("#Phone").val(response.data.Phone); $("#Birthday").val(response.data.Birthday); - $("#NumberID").val(response.data.NumberId); + $("#NumberId").val(response.data.NumberId); $("#Address").val(response.data.Address); $("#TextName").html(response.data.Name); $("#TextEmail").html(response.data.Email); diff --git a/Backend/Views/Shared/_Layout.cshtml b/Backend/Views/Shared/_Layout.cshtml index c3be4c9..8ce0899 100644 --- a/Backend/Views/Shared/_Layout.cshtml +++ b/Backend/Views/Shared/_Layout.cshtml @@ -3,12 +3,11 @@ - - + Online Banking - Group 1 - C1905M BKAP diff --git a/Backend/Views/Transactions/Index.cshtml b/Backend/Views/Transactions/Index.cshtml index b659ba8..f07f25f 100644 --- a/Backend/Views/Transactions/Index.cshtml +++ b/Backend/Views/Transactions/Index.cshtml @@ -238,7 +238,7 @@ $(document).on('blur', '#ToId', function () { let dataInfoBankAccount; - if (this.value.length === 0) { + if (this.value.trim().length === 0) { $('#text2').css('display', 'none'); $('#infoReceiver').css('display', 'none'); } else { diff --git a/Backend/Web.config b/Backend/Web.config index 18ff9c5..6badf91 100644 --- a/Backend/Web.config +++ b/Backend/Web.config @@ -63,8 +63,8 @@ - - + + diff --git a/OnlineBanking.BLL/Repositories/Repository.cs b/OnlineBanking.BLL/Repositories/Repository.cs index 801c08f..583bfa4 100644 --- a/OnlineBanking.BLL/Repositories/Repository.cs +++ b/OnlineBanking.BLL/Repositories/Repository.cs @@ -17,7 +17,7 @@ namespace OnlineBanking.BLL.Repositories public Repository() { - cnn = new ApplicationDbContext(); ; + cnn = new ApplicationDbContext(); tbl = cnn.Set(); } @@ -90,6 +90,7 @@ public bool Edit(T e) cnn.Entry(e).State = EntityState.Modified; cnn.SaveChanges(); return true; + } catch (Exception) { diff --git a/OnlineBanking.DAL/OnlineBanking.DAL.csproj b/OnlineBanking.DAL/OnlineBanking.DAL.csproj index add7a39..d04462a 100644 --- a/OnlineBanking.DAL/OnlineBanking.DAL.csproj +++ b/OnlineBanking.DAL/OnlineBanking.DAL.csproj @@ -87,6 +87,7 @@ + diff --git a/OnlineBanking.DAL/ViewModel/AccountViewModel.cs b/OnlineBanking.DAL/ViewModel/AccountViewModel.cs index 7d72ac3..1b9e1aa 100644 --- a/OnlineBanking.DAL/ViewModel/AccountViewModel.cs +++ b/OnlineBanking.DAL/ViewModel/AccountViewModel.cs @@ -34,7 +34,7 @@ public AccountViewModel(Accounts account) public string NumberId { get; set; } public int? Status { get; set; } public string StatusName { get; set; } // active, delete, lock - public int? RoleId { get; set; } // Quyền + public int RoleId { get; set; } // Quyền public string RoleName { get; set; } // Quyền public string CreatedAt { get; set; } public string UpdatedAt { get; set; } diff --git a/OnlineBanking.DAL/ViewModel/AdminChangePasswordViewModels.cs b/OnlineBanking.DAL/ViewModel/AdminChangePasswordViewModels.cs new file mode 100644 index 0000000..bdd6cfc --- /dev/null +++ b/OnlineBanking.DAL/ViewModel/AdminChangePasswordViewModels.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OnlineBanking.DAL +{ + public class AdminChangePasswordViewModels + { + public int AccountId { get; set; } + [Required] + [MinLength(6)] + public string Password { get; set; } + [Required] + [MinLength(6)] + public string RePassword { get; set; } + } +}