예제 #1
0
        public async Task <IActionResult> Edit(string id, [FromForm] UserEditPageModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var user = await _userService.GetAsync(model.Id);

            if (user == null)
            {
                return(RedirectToAction(nameof(Overview)));
            }

            user.Email       = model.Email;
            user.UserName    = model.UserName;
            user.PhoneNumber = model.PhoneNumber;

            try
            {
                await _userService.UpdateAsync(user);

                return(RedirectToAction(nameof(Overview), new { success = true }));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex));
            }
        }