public async void UpdateUserAuth_AtInitializedDbTable_UpdatedUserAuthEqualExpectedUserAuth() { // arrange var userAuth = GetUserAuth(); userAuth.PasswordHash = "notHashOfficer"; fixture.dbAuth.Add(userAuth); await fixture.dbAuth.SaveChangesAsync(); var userAuthUpdateModel = new UserAuthUpdateModel { Login = "******", PasswordNew = "tetriandoh", PasswordNewConfirm = "tetriandoh" }; var expected = new UserAuth { Login = "******", PasswordHash = "hash" }; // act await logic.UpdateDataModelAsync(userAuthUpdateModel); // assert var actual = await fixture.dbAuth.UserAuth.FirstOrDefaultAsync(i => i.Login == userAuth.Login); Assert.Equal(expected.Login, actual.Login); Assert.Equal(expected.PasswordHash, actual.PasswordHash); }
/// <summary> /// Update user security data. /// </summary> /// <param name="model">Updated user security data information</param> public async Task UpdateDataModelAsync(UserAuthUpdateModel model) { var currentModel = await db.UserAuth.FirstOrDefaultAsync(i => i.Login == model.Login); var userAuth = new UserAuth { Login = model.Login, PasswordHash = genPasswordHash.GenerateHash(model.PasswordNew) }; db.Entry(currentModel).CurrentValues.SetValues(userAuth); await db.SaveChangesAsync(); }
public async Task <IResultModel> Update(UserAuthUpdateModel model) { var entity = await _repository.FirstAsync(model.Id); if (entity == null) { return(ResultModel.NotExists); } _mapper.Map(model, entity); var result = await _repository.UpdateAsync(entity); return(ResultModel.Result(result)); }
public async Task <IActionResult> EditSingleItem(UserAuthUpdateModel model) { var statusMessage = await logicValidation.CheckUpdateUserAuthUpdateModelAsync(model.Login, model.PasswordOld); if (statusMessage.IsCompleted) { await logic.UpdateDataModelAsync(model); await logProvider.AddToLogAsync($"Updated user information (Id: {model.Login})."); return(RedirectToRoute(UserManagmentRouting.Index)); } else { return(View("CustomError", statusMessage)); } }
public Task <IResultModel> Update(UserAuthUpdateModel model) { return(_service.Update(model)); }