Пример #1
0
 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);
     }
 }
Пример #2
0
 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();
 }
Пример #3
0
 public void Delete(Roles model)
 {
     var target = IncludeFind(model.ID);
     DB_Service.Remove<Roles>(target);
     DB_Service.Commit();
 }
Пример #4
0
 public void Create(Roles model)
 {
     DB_Service.Add<Roles>(model);
     DB_Service.Commit();
 }
Пример #5
0
 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);
 }