public async Task <IActionResult> Save(UserViewModel model) { if (ModelState.IsValid) { try { if (model.UserId == 0) { model = await UsersBL.CreateUser(_context, _userManager, model); if (!string.IsNullOrEmpty(model.ErrorText)) { throw new Exception(model.ErrorText); } } else { model = UsersBL.EditUserProfile(_context, model); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } return(PartialView("CreateEdit", model)); }