Пример #1
0
        public IActionResult Edit(string id, ApplicationUserEditModel applicationUserEditModel)
        {
            if (id != applicationUserEditModel.Id)
            {
                return(RedirectToAction("Not_Found", "Home"));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _service.EditApplicationUser(applicationUserEditModel);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ApplicationUserExists(applicationUserEditModel.Id.ToString()))
                    {
                        return(RedirectToAction("Not_Found", "Home"));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Users)));
            }
            return(View(applicationUserEditModel));
        }
Пример #2
0
        public async Task <IActionResult> Edit([FromBody] EditUserViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            IdentityResult res = await _applicationUserService.EditApplicationUser(model);

            if (!res.Succeeded)
            {
                return(BadRequest(420));
            }

            return(Ok(201));
        }