// POST: Groups/Create public ActionResult Create(CreateUserGroupViewModel model) { if (ModelState.IsValid) { using (var db = new ApplicationDbContext()) { var group = new UserGroup { Name = model.Name }; group.Members.Add(db.Users.Find(User.Identity.GetUserId())); db.UserGroups.Add(group); db.SaveChanges(); return(RedirectToAction("Index", "Groups")); } } //Something went wrong return(View("Error")); }
public IActionResult CreateUserGroup(FormCollection formCollection, CreateUserGroupViewModel createUserGroupViewModel) { //aUserGroup.istrUserIds = formCollection["txtUserIds"]; //aUserGroup.idoUserGroup.iintUserId = Convert.ToInt32(HttpContext.Session.GetInt32("UserId")); //if (aUserGroup.idoUserGroup.userGroupId == 0) //{ // aUserGroup = new AdminService().CreateUserGroup(aUserGroup); // if (aUserGroup.ilstMessages != null && !aUserGroup.ilstMessages.Any(lMessage => lMessage.idoMessage.severityValue == "ERRR")) // { // ViewData[Constant.ValidationMessages] = aUserGroup.ilstMessages; // return RedirectToAction("CreateUserGroup", new { aintUserGroupId = 0 }); // } // else // { // return View(aUserGroup); // } //} //else //{ // aUserGroup = new AdminService().UpdateUserGroup(aUserGroup); // if (aUserGroup.ilstMessages != null && !aUserGroup.ilstMessages.Any(lMessage => lMessage.idoMessage.severityValue == "ERRR")) // { // ViewData[Constant.ValidationMessages] = aUserGroup.ilstMessages; // return RedirectToAction("UserGroups"); // } // else // { // return View(aUserGroup); // } //} return(View()); }