public ActionResult Edit(Models.User user) { if (ModelState.IsValid) { var userEdit = new Domain.User(); userEdit.InjectFrom(user); userService.UpdateUser(userEdit); TempData["message"] = string.Format("{0} has been saved", user.Firstname); } else { return(View(user)); } return(RedirectToAction("Index")); }
public ActionResult Create(User model) { if (ModelState.IsValid) { var dbModel = new Domain.User(); dbModel.InjectFrom(model); _userService.AddUser(dbModel); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Create(Models.User model) { if (ModelState.IsValid) { if (!userService.ExistsUser(model.Email, model.UserName)) { var dbModel = new Domain.User(); dbModel.InjectFrom(model); //filmRepository.Add(dbModel); userService.AddUser(dbModel); TempData["message"] = string.Format("{0} has been saved", model.Firstname); } else { ModelState.AddModelError("Email", "Can't add an email that is already in the database!"); ModelState.AddModelError("UserName", "Can't add an email that is already in the database!"); //Roles var roles = roleRepository.GetAll(); var rolesList = roles.Select(r => new SelectListItem() { Value = r.Id.ToString(), Text = r.RoleName }).ToList(); //Reservationss var reservations = reservationRepository.GetAll(); var reservationList = reservations.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.ShowId.ToString() }).ToList(); ViewBag.Roles = rolesList; ViewBag.ReservationId = reservationList; return(View(model)); } return(RedirectToAction("Index")); } return(View(model)); }