public IActionResult Modify(ModifyCurrentUserModel model) { if (!AuthorizeService.AuthorizeUser(User, model.Id)) { return(RedirectToAction("AccessDenied", "Auth")); } else { if (ModelState.IsValid) { User user = ModelConverter.ConvertFromUserModifyCurrnetUserModel(model); Response response = UserService.UpdateUser(user); if (response.IsSuccessful) { return(RedirectToAction("Success")); } else { ModelState.AddModelError(string.Empty, response.Message); return(View(model)); } } else { return(View(model)); } } }
public static User ConvertFromUserModifyCurrnetUserModel(ModifyCurrentUserModel currentUserModel) { return(new User { Id = currentUserModel.Id, UserName = currentUserModel.Username, }); }
public IActionResult Modify(int id) { if (!AuthorizeService.AuthorizeUser(User, id)) { return(RedirectToAction("AccessDenied", "Auth")); } else { ModifyCurrentUserModel model = ModelConverter.ConvertToModifyCurrentUserModel(UserService.GetById(id)); return(View(model)); } }