public ActionResult Create(UserViewModel model) { if (ModelState.IsValid) return TryCreateUser(model); return IndexErrorCreate(model); }
private void UpdateUserModel(UserViewModel targetUser, UserViewModel sourceUser) { targetUser.Email = sourceUser.Email; targetUser.FirstName = sourceUser.FirstName; targetUser.LastName = sourceUser.LastName; targetUser.SelectedRole = sourceUser.SelectedRole; }
public ActionResult Update(UserViewModel model) { if (ModelState.IsValid) return TryUpdateUser(model); return IndexUpdate(model); }
private void UpdateUserModel(UserManagementViewModel indexModel, UserViewModel userModel) { var user = (from u in indexModel.UserList where u.Id.Equals(userModel.Id) select u).FirstOrDefault(); if (user != null) UpdateUserModel(user, userModel); }
internal static User MapUserManagementModelToUser(UserViewModel model) { return new User() { Id = model.Id, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, Role = model.SelectedRole.GetRole(), }; }
private ActionResult TryCreateUser(UserViewModel model) { try { var newUser = CreateUser(this.SecurityToken, model); TryAssignCase(this.SecurityToken, newUser.Id, model.SelectedCase); return RedirectToAction("Index"); } catch (DuplicateUserException) { AddModelStateError(GlobalStrings.DuplicatedUser); } catch (Exception) { AddModelStateError(GlobalStrings.SomethingWentWrong); } return IndexErrorCreate(model); }
private ActionResult TryUpdateUser(UserViewModel model) { try { var user = Mappers.MapUserManagementModelToUser(model); this.Service.UpdateUser(this.SecurityToken, user); return IndexUpdate(model); } catch (UserDoesNotExistException) { AddModelStateError(GlobalStrings.UserDoesNotExists); } catch (Exception) { AddModelStateError(GlobalStrings.SomethingWentWrong); } return IndexUpdate(model); }
private ActionResult IndexErrorCreate(UserViewModel model) { var modelWithError = CreateBaseUserManagementVewModel(); MapExistingUserModel(modelWithError, model); ViewBag.ShowUserCreation = true; return View("Index", modelWithError); }
private User CreateUser(string token, UserViewModel model) { var user = Mappers.MapUserManagementModelToUser(model); return this.Service.CreateUser(token, user); }
private void MapExistingUserModel(UserManagementViewModel modelWithError, UserViewModel model) { modelWithError.NewUser.FirstName = model.FirstName; modelWithError.NewUser.LastName = model.LastName; modelWithError.NewUser.Email = model.Email; modelWithError.NewUser.SelectedCase = model.SelectedCase; modelWithError.NewUser.SelectedRole = model.SelectedRole; }
private ActionResult IndexUpdate(UserViewModel model) { return PartialView("Details", model); }
private void TryAddCases(string token, UserViewModel model) { var cases = GetCases(token); SetCasesJson(cases); model.Cases = GetCasesForNewUser(cases); }