Пример #1
0
        public ActionResult Create(GroupModel model)
        {
            var roles = GetForeignData();
            ViewBag.Data_RolesList = roles;

            if (ModelState.IsValid)
            {
                try
                {
                    Group gps = new Group();
                    gps.Name = model.Name;
                    gps.Description = model.Description;
                    var rolesArray = model.RolesList.Split(',').Select(x => Convert.ToInt32(x));
                    var RoleList = roleService.GetALL(rolesArray);
                    gps.Roles.AddRange(RoleList);
                    groupService.Create(gps);
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    return View(model);
                }
            }
            else
            {
                return View(model);
            }
        }
Пример #2
0
 public void Update(Group model)
 {
     var target = Find(model.GroupID);
     DB_Service.Attach<Group>(target);
     target.Name = model.Name;
     target.Description = model.Description;
     DB_Service.Commit();
 }
Пример #3
0
 public void Delete(Group model)
 {
     var target = IncludeFind(model.GroupID);
     DB_Service.Remove<Group>(target);
     DB_Service.Commit();
 }
Пример #4
0
 public void Create(Group model)
 {
     DB_Service.Add<Group>(model);
     DB_Service.Commit();
 }
Пример #5
0
 public ActionResult Edit(int id)
 {
     GroupModel gpm = new GroupModel();
     Group gps = new Group();
     gps = groupService.IncludeFind(id);
     gpm.ID = gps.GroupID;
     gpm.Name = gps.Name;
     gpm.Description = gps.Description;
     List<int> RolesList = new List<int>();
     RolesList = gps.Roles.Select(x => x.ID).ToList();
     var roles = GetForeignData(RolesList);
     ViewBag.Data_RolesList = roles;
     return View(gpm);
 }