예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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());
        }
예제 #4
0
        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 }));
        }