public async Task <IActionResult> EditAccount(int id, [Bind("accountName", "email", "isActived", "typeAccount", "lastName", "firstName")] EditAccount reqEditAccount) { if (ModelState.IsValid) { var account = _context.Accounts.FirstOrDefault(p => p.ID == id); if (_context.Accounts.FirstOrDefault(p => p.accountName == reqEditAccount.accountName && p.accountName != account.accountName) != null) { ModelState.AddModelError("", "Tên đăng nhập đã tồn tại"); return(View()); } account.accountName = reqEditAccount.accountName; account.email = reqEditAccount.email; account.isActived = reqEditAccount.isActived; account.typeAccount = reqEditAccount.typeAccount; account.lastName = reqEditAccount.lastName; account.firstName = reqEditAccount.firstName; _context.Update(account); await _context.SaveChangesAsync(); return(RedirectToAction("ListAccounts")); } return(View()); }
public OperationResult Edit(EditAccount command) { var operation = new OperationResult(); var editItem = _accountRepository.Get(command.Id); if (editItem == null) { return(operation.Failed(ApplicationMessages.RecordNotFound)); } if (_accountRepository.Exist(x => (x.Username == command.Username || x.Mobile == command.Mobile) && x.Id != command.Id)) { return(operation.Failed(ApplicationMessages.DuplicatedRecord)); } var ImageFolderName = Tools.ToFolderName(this.GetType().Name); string ImagePath; if (command.ProfilePhoto != null) { ImagePath = $"{ImageFolderName}/{command.Fname}-{command.Lname}"; } else { ImagePath = $"{ImageFolderName}"; } var filepath = _fileUploader.Upload(command.ProfilePhoto, ImagePath); editItem.Edit(command.Fname, command.Lname, command.Username, command.Mobile, command.RoleId, filepath); _accountRepository.SaveChanges(); return(operation.Succedded()); }
public async Task <ViewResult> Edit(EditAccount model) { // Test model if (ModelState.IsValid) { // Get current user from session UserProfile user = _userService.Get(); // Update editable data user.Name = model.User.Name; user.Email = model.User.Email; // update database // Try to save changes var result = _dataService.EditUser(user); // Send mail if requested if (result?.MailChanged ?? false) { await _mailService.SendValidationMail(user.Id); } model.Success = result?.Result; // Refresh model.User = user; // Update the inforamtion for the userservice _userService.Set(user); } return(View(model)); }
private void UserEdit_Click(object sender, RoutedEventArgs e) { EditAccount ed_Account = new EditAccount(currentUser); this.Close(); ed_Account.Show(); }
private void Listbox_Accounts_Edit(object sender, RoutedEventArgs e) { EditAccount EditWin = new EditAccount(); EditWin.Owner = this; EditWin.Show(); }
public OperationResult Edit(EditAccount command) { var operation = new OperationResult(); var account = _accountRepository.Get(command.Id); if (account == null) { return(operation.Failed(ApplicationMessages.RecordNotFound)); } if (_accountRepository.Exists(x => (x.Username == command.Username || x.Mobile == command.Mobile) && x.Id != command.Id)) { return(operation.Failed(ApplicationMessages.DuplicatedRecord)); } const string path = "ProfilePhotos"; var picturePath = _fileUploader.Upload(command.ProfilePhoto, path); account.Edit(command.Fullname, command.Username, command.Mobile, command.RoleId, picturePath); _accountRepository.SaveChanges(); return(operation.Succeed()); }
public void OnGet() { var account = _authHelper.CurrentAccountId(); Orders = _orderQuery.GetOrderBy(account); AccountInfo = _orderQuery.GetAccountInformation(account); PersonalInfo = _orderQuery.GetPersonalInfoItemBy(account); GetAccountDetails = _accountApplication.GetDetails(account); }
public IActionResult OnPostEdit(EditAccount command) { var result = new OperationResult(); if (ModelState.IsValid) { result = _accountApplication.Edit(command); } return(new JsonResult(result)); }
public async Task OnGetAsync() { Account = new EditAccount { Id = -1, Number = await _accountQueries.GetNextNumber(), CreationDate = _timeService.ClientLocalNow.ToStandardString(false) }; AccountTypes = AccountTypeHelper.GetAllHumanNames(); }
public IActionResult OnPostChangePassword(ChangePassword command) { GetAccountDetails = _accountApplication.GetDetails(command.Id); command.Id = GetAccountDetails.Id; var password = _accountApplication.ChangePassword(command); return(RedirectToPage("/UserDashboard", password)); }
public void edit_account() { EditAccount ed = new EditAccount(webdriver.driver); ed.edit_account(ConfigurationManager.AppSettings["edit_account_id"]); EditAccountFormPage ed_acc = new EditAccountFormPage(webdriver.driver); ed_acc.edit_account(); }
public IActionResult OnPostEdit(EditAccount command) { GetAccountDetails = _accountApplication.GetDetails(command.Id); command.Id = GetAccountDetails.Id; command.RoleId = GetAccountDetails.RoleId; var account = _accountApplication.Edit(command); return(RedirectToPage("/UserDashboard", account)); }
private async void ListView_DoubleTapped(object sender, Windows.UI.Xaml.Input.DoubleTappedRoutedEventArgs e) { var activeAccount = (IAccount)(((ListView)sender).SelectedValue); var editAccount = new EditAccount(activeAccount); var result = await editAccount.ShowAsync(); if (result == ContentDialogResult.Primary) { ViewModel.Refresh(); } }
private async void AppBarButton_Click(object sender, RoutedEventArgs e) { var addAccount = new EditAccount(); var result = await addAccount.ShowAsync(); if (result == ContentDialogResult.Primary) { ViewModel.Refresh(); } }
public void changePassword() { string name = "Test User"; string passwordHash = "e16b2ab8d12314bf4efbd6203906ea6c"; Admin admin = new Admin("E1000", "User", false); EditAccount editAcc = new EditAccount(admin); Assert.IsTrue(editAcc.changePassword(passwordHash, name)); }
public async Task EditAccountAsync(EditAccount command) { var account = await accountRepository.GetAccountAsync(command.Id); account.Edit(command.Name, command.CurrencyId, command.AccountGroupId, command.IsIncludedInTotal, command.Comment, command.Order, command.Type, command.ParentAccountId, command.IsActive); await accountRepository.UpdateAsync(account); if (account.Type != AccountType.Card) { await this.accountRepository.BalanceAdjustmentAsync(account.Id, command.Amount); } }
public ActionResult EditAccount(EditAccount editAccount) { if (!ModelState.IsValid) { MessageForClient(ActionStatus.Error, $"Указанные данные не валидны."); return(View("~/Views/Account/EditAccount.cshtml")); } var repositoryResult = _userRepository.FindUser(editAccount.Login); if (repositoryResult.Status != ActionStatus.Success) { MessageForClient(repositoryResult.Status, repositoryResult.Message); return(View("~/Views/Home/Index.cshtml")); } var userFromDb = repositoryResult.Entity.First() as UserBase; if (editAccount.Password != userFromDb.Password) { MessageForClient(ActionStatus.Error, $"Введен неверный пароль!"); return(View("~/Views/Account/EditAccount.cshtml")); } if (!string.IsNullOrWhiteSpace(editAccount.NewLogin)) { if (_userRepository.FindUser(editAccount.NewLogin).Status == ActionStatus.Success) { MessageForClient(ActionStatus.Error, $"Пользователь с логином ({editAccount.NewLogin}) уже существует, выберите пожалуйста другой логин!"); return(View("~/Views/Account/EditAccount.cshtml")); } userFromDb.Login = editAccount.NewLogin; } if (!string.IsNullOrWhiteSpace(editAccount.NewPassword)) { userFromDb.Password = editAccount.NewPassword; } if (string.IsNullOrWhiteSpace(editAccount.NewPassword) && string.IsNullOrWhiteSpace(editAccount.NewLogin)) { MessageForClient(ActionStatus.Success, $"Вы остались при своих регистрационных данных."); return(RedirectToAction("ShowUser", "User", new { editAccount.Login })); } var savedResult = _userRepository.UpdateUser(userFromDb); MessageForClient(savedResult.Status, savedResult.Message); if (savedResult.Status != ActionStatus.Success) { return(RedirectToAction("ShowUser", "User", new { editAccount.Login })); } var savedUser = savedResult.Entity.First() as UserBase; FormsAuthentication.SignOut(); FormsAuthentication.SetAuthCookie(savedUser.Login, true); return(RedirectToAction("ShowUser", "User", new { savedUser.Login })); }
private void EditAccountExecute() { EditAccount view = new EditAccount(); view.DataContext = new EditAccountViewModel(view, SelectItem.Ssn); view.Owner = mWindow; bool?result = view.ShowDialog(); if (result == true) { ReFreshAccountExecute(); } }
/// <summary> /// Get Edit /// </summary> /// <returns></returns> public ActionResult Edit() { // Get current user UserProfile user = _userService.GetFreshUseerUpdatedFromDataBase(); if (user == null) { return(NotFound()); } // Set model EditAccount model = new EditAccount { User = user, Success = null // none action done at this time }; return(View(model)); }
private void SubmitClick(object sender, RoutedEventArgs e) { try { string newPassword = newPasswordBox.Text; EditAccount editAccount = new EditAccount(newPassword); var mainMenu = new MainMenu(); MessageBox.Show("Password updated successfully."); mainMenu.Show(); this.Close(); } catch (Exception) { MessageBox.Show("Something went wrong."); var mainMenu = new MainMenu(); mainMenu.Show(); this.Close(); } }
public async Task <AccountResponse> EditAccountAsync(EditAccount account) { AccountEntity accountEntity = JsonConvert.DeserializeObject <AccountEntity>(JsonConvert.SerializeObject(account)); var resp = await _accountRepo.EditAccountAsync(accountEntity); if (resp == 1) { return new AccountResponse { RequestID = account.RequestID, StatusCode = "00", Message = "Successfully Changed" } } ; else { throw new BadRequestException(new GeneralResponse { code = "400", message = "Failed To Modify Account" }); } }
private void DoEditAccount(EditAccount req) { var db = new BillingwareDataContext(); var account = db.Accounts.FirstOrDefault(a => a.AccountNumber == req.AccountNumber); if (account == null) { Sender.Tell(new AccountEdited(new CommonStatusResponse(message: "Not found", code: "404", subCode: "404.1")), Self); return; } account.Alias = req.Alias; account.Extra = req.Extra; db.Entry(account).State = EntityState.Modified; db.SaveChanges(); Sender.Tell(new AccountEdited(new CommonStatusResponse(message: "Successful")), Self); }
private void cmdEditAccount_Click(object sender, RoutedEventArgs e) { if (lstAccounts.SelectedItem == null) { MessageBox.Show("No account selected"); } else { var account = lstAccounts.SelectedItem as Account; var dialog = new EditAccount(account); dialog.Owner = this; var result = dialog.ShowDialog(); if (result == true) { lstAccounts.Items.Refresh(); } } }
public OperationResult Edit(EditAccount command) { var operationResult = new OperationResult(); var editAccount = _accountRepository.Get(command.Id); if (editAccount == null) { return(operationResult.Failed(QueryValidationMessage.NotFound)); } if (_accountRepository.Exists(x => (x.Username == command.Username || x.Mobile == command.Mobile) && x.Id != command.Id)) { return(operationResult.Failed(QueryValidationMessage.DuplicateRecord)); } var profilePhoto = _fileUploader.FileUpload(command.ProfilePhoto, "ProfilePhotos"); editAccount.Edit(command.Fullname, command.Username, command.Mobile, command.RoleId, profilePhoto); _accountRepository.SaveChanges(); return(operationResult.Succeeded()); }
public OperationResult Edit(EditAccount command) { var operationResult = new OperationResult(); var Account = _accountRepo.Get(command.Id); if (Account == null) { return(operationResult.Failed(ApplicationMessage.recordNotFound)); } if (_accountRepo.Exists(c => (c.Username == command.Username || c.Mobile == command.Mobile) && c.Id != command.Id)) { return(operationResult.Failed(ApplicationMessage.duplicated)); } var path = $"ProfileImage"; var Picturepath = _fileUploader.Upload(command.ProfilePicture, path); Account.Edit(command.FullName, command.Username, command.Mobile, command.RoleId, Picturepath); _accountRepo.Save(); return(operationResult.Succeeded()); }
public JsonResult OnPostEdit(EditAccount command) { var result = _accountApplication.Edit(command); return(new JsonResult(result)); }
public EditAccountPage ClickLinkEditAccount() { EditAccount.Click(); return(new EditAccountPage()); }
public OperationResult Edit(EditAccount command) { throw new System.NotImplementedException(); }
public virtual HttpResponseMessage Put(EditAccount editAccount) { throw new NotImplementedException(); }
public async Task <AccountResponse> Modify(EditAccount account) => await _account.EditAccountAsync(account);