public IActionResult Profile(EditProfileRequest request) { if (!ModelState.IsValid) { return(RedirectToAction(nameof(Profile))); } Result editResult = _manageUserService.EditUser(GetUserId(), request); Result <ProfileViewModel> getResult = _manageDataService.GetProfile(GetUserId()); if (getResult.Failure) { ModelState.AddErrors(getResult.Errors); return(View()); } if (editResult.Failure) { getResult.Value.StatusAlert = StatusAlertViewExtension.Get(editResult); ModelState.AddErrors(editResult.Errors); return(View()); } getResult.Value.StatusAlert = StatusAlertViewExtension.Get("Profile updated"); return(View(getResult.Value)); }
public async Task <IActionResult> Edit(string id, EditUserRequest model) { if (!ModelState.IsValid) { return(NotFoundView()); } Result editResult = await _manageUserService.EditUser(id, model, GetUserId()); Result <UserDetailsViewModel> userResult = _userDataService.GetDetailsViewModel(id); if (userResult.Failure) { return(NotFoundView()); } if (editResult.Failure) { ModelState.AddErrors(editResult.Errors); userResult.Value.StatusAlert = StatusAlertViewExtension.Get(editResult); return(View("Details", userResult.Value)); } userResult.Value.StatusAlert = StatusAlertViewExtension.Get("User updated"); return(View("Details", userResult.Value)); }
public async Task <IActionResult> Update([FromRoute] long groupUserId, [FromBody] EditUserRequest editUserRequest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Result editResult = await _manageUserService.EditUser(groupUserId, editUserRequest); return(editResult.ToApiResult()); }
public async Task <IActionResult> Edit(string id, EditUserRequest model) { if (!ModelState.IsValid) { return(NotFoundView()); } Result editResult = await _manageUserService.EditUser(id, model, GetUserId()); if (editResult.Failure) { SaveTempData(TEMP_DATA_STATUS_ALERT_KEY, StatusAlertViewExtension.Get(editResult)); } else { SaveTempData(TEMP_DATA_STATUS_ALERT_KEY, StatusAlertViewExtension.Get("User updated")); } return(RedirectToAction(nameof(Details), new { id })); }