Esempio n. 1
0
        public ActionResult Create(RoleViewModel model)
        {
            ServiceResult result = new ServiceResult();
            if (ModelState.IsValid)
            {
                try
                {
                    RoleService.Create(model);
                    result.Message = "添加角色成功!";
                    LogHelper.WriteLog("添加角色成功");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("添加角色错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }

            return Json(result);
        }
Esempio n. 2
0
        public ActionResult Create()
        {
            var model = new RoleViewModel();
            //ViewBag.ActionID_LoadUrl = Url.Action("GetActionComboTree", "AjaxService");

            ViewBag.ActionID_LoadUrl = Url.Action("GetActionComboTree", "AjaxService");
            ViewBag.ActionID_Prefix = "c_";
            return PartialView(model);
        }
Esempio n. 3
0
 public Role Create(RoleViewModel model)
 {
     var entity = new Role();
     entity.Name = model.Name;
     entity.Description = model.Description;
     if (!string.IsNullOrEmpty(model.ActionID))
     {
         var ActionArray = Utilities.GetIdList(model.ActionID);
         var ActionList = ActionService.GetALL().Where(x => ActionArray.Contains(x.ID));
         entity.Action.AddRange(ActionList);
     }
     db.Add<Role>(entity);
     db.Commit();
     return entity;
 }
Esempio n. 4
0
 public Role Update(RoleViewModel model)
 {
     var entity = Find(model.ID);
     db.Attach<Role>(entity);
     entity.Name = model.Name;
     entity.Description = model.Description;
     var ActionArray = new List<int>();
     if (string.IsNullOrEmpty(model.ActionID))
     {
         entity.Action = new List<CommonP.Models.Action>();
     }
     else
     {
         ActionArray = Utilities.GetIdList(model.ActionID);
         var ActiontList = ActionService.GetALL().Where(x => ActionArray.Contains(x.ID));
         var currentActionArray = entity.Action.Select(x => x.ID).ToList();
         foreach (CommonP.Models.Action ac in ActionService.GetALL())
         {
             if (ActionArray.Contains(ac.ID))
             {
                 if (!currentActionArray.Contains(ac.ID))
                 {
                     entity.Action.Add(ac);
                 }
             }
             else
             {
                 if (currentActionArray.Contains(ac.ID))
                 {
                     entity.Action.Remove(ac);
                 }
             }
         }
     }
     db.Commit();
     return entity;
 }
Esempio n. 5
0
        public ActionResult Edit(int ID)
        {
            var entity = RoleService.GetALL().Include(x => x.Action).Single(x => x.ID == ID);
            string ActionID = string.Join(",", entity.Action.Select(x => x.ID.ToString()));
            var model = new RoleViewModel()
            {
                ID = entity.ID,
                Description = entity.Description,
                Name = entity.Name,
                ActionID = ActionID
            };

            //ViewBag.ActionID_LoadUrl = Url.Action("GetActionGroupCombox", "AjaxService", new { ActionID = ActionID });
            ViewBag.ActionID_Prefix = "c_";
            ViewBag.ActionID_LoadUrl = Url.Action("GetActionComboTree", "AjaxService", new { ActionID = ActionID });
            return PartialView(model);
        }