Esempio n. 1
0
 public override bool Create(ref ValidationErrors errors, SysModuleModel model)
 {
     try
     {
         SysModule entity = m_Rep.GetById(model.Id);
         if (entity != null)
         {
             errors.Add(Suggestion.PrimaryRepeat);
             return(false);
         }
         entity              = new SysModule();
         entity.Id           = model.Id;
         entity.Name         = model.Name;
         entity.EnglishName  = model.EnglishName;
         entity.ParentId     = model.ParentId;
         entity.Url          = model.Url;
         entity.Iconic       = model.Iconic;
         entity.Sort         = model.Sort;
         entity.Remark       = model.Remark;
         entity.Enable       = model.Enable;
         entity.CreatePerson = model.CreatePerson;
         entity.CreateTime   = model.CreateTime;
         entity.IsLast       = model.IsLast;
         if (m_Rep.Create(entity) == true)
         {
             //分配给角色
             db.P_Sys_InsertSysRight();
             return(true);
         }
         else
         {
             errors.Add(Suggestion.InsertFail);
             return(false);
         }
     }
     catch (Exception ex)
     {
         errors.Add(ex.Message);
         ExceptionHander.WriteException(ex);
         return(false);
     }
 }
Esempio n. 2
0
 public override bool Create(ref ValidationErrors errors, SysRoleModel model)
 {
     try
     {
         SysRole entity = m_Rep.GetById(model.Id);
         if (entity != null)
         {
             errors.Add(Suggestion.PrimaryRepeat);
             return(false);
         }
         entity              = new SysRole();
         entity.Id           = model.Id;
         entity.Name         = model.Name;
         entity.Description  = model.Description;
         entity.CreateTime   = model.CreateTime;
         entity.CreatePerson = model.CreatePerson;
         if (m_Rep.Create(entity))
         {
             //分配给角色
             db.P_Sys_InsertSysRight();
             //清理无用的项
             db.P_Sys_ClearUnusedRightOperate();
             return(true);
         }
         else
         {
             errors.Add(Suggestion.InsertFail);
             return(false);
         }
     }
     catch (Exception ex)
     {
         errors.Add(ex.Message);
         ExceptionHandler.WriteException(ex);
         return(false);
     }
 }