public ActionResult Create(RoleModel model) { var permissions = GetGroupForeignData(); ViewBag.Data_Permissions = permissions; if (ModelState.IsValid) { try { Roles rls = new Roles(); rls.Name = model.Name; rls.Description = model.Description; var permissionsArray = model.Permissions.Split(',').Select(x => Convert.ToInt32(x)).ToList(); var PermissionList = permissionService.GetALL(permissionsArray); rls.Permissions.AddRange(PermissionList); roleService.Create(rls); return RedirectToAction("index"); } catch (Exception ex) { ViewBag.Message = ex.Message; return View(model); } } else { return View(model); } }
public void Update(Roles model) { var target = Find(model.ID); DB_Service.Attach<Roles>(target); target.Name = model.Name; target.Description = model.Description; DB_Service.Commit(); }
public void Delete(Roles model) { var target = IncludeFind(model.ID); DB_Service.Remove<Roles>(target); DB_Service.Commit(); }
public void Create(Roles model) { DB_Service.Add<Roles>(model); DB_Service.Commit(); }
public ActionResult Edit(int id) { RoleModel rml = new RoleModel(); Roles rs = new Roles(); rs = roleService.IncludePermissionsFind(id); rml.ID = rs.ID; rml.Name = rs.Name; rml.Description = rs.Description; List<int> PermissionsList = new List<int>(); PermissionsList = rs.Permissions.Select(x => x.ID).ToList(); var permissions = GetGroupForeignData(PermissionsList); ViewBag.Data_Permissions = permissions; return View(rml); }