예제 #1
0
 public 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) == 1)
         {
             //分配给角色
             dbContainer.P_Sys_InsertSysRight();
             //清理无用的项
             dbContainer.P_Sys_ClearUnusedRightOperate();
             return true;
         }
         else
         {
             errors.Add(Suggestion.InsertFail);
             return false;
         }
     }
     catch (Exception ex)
     {
         errors.Add(ex.Message);
         ExceptionHander.WriteException(ex);
         return false;
     }
 }
예제 #2
0
        public JsonResult Create(SysRoleModel model)
        {
            model.Id = ResultHelper.NewId;
            model.CreateTime = ResultHelper.NowTime;
            if (model != null && ModelState.IsValid)
            {

                if (m_BLL.Create(ref errors, model))
                {
                    m_Log.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name, "成功", "创建", "SysRole");
                    return Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed));
                }
                else
                {
                    string ErrorCol = errors.Error;
                    m_Log.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name + "," + ErrorCol, "失败", "创建", "SysRole");
                    return Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol));
                }
            }
            else
            {
                return Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail));
            }
        }
예제 #3
0
        public JsonResult Edit(SysRoleModel model)
        {
            if (model != null && ModelState.IsValid)
            {

                if (m_BLL.Edit(ref errors, model))
                {
                    m_Log.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name, "成功", "修改", "SysRole");
                    return Json(JsonHandler.CreateMessage(1, Suggestion.EditSucceed));
                }
                else
                {
                    string ErrorCol = errors.Error;
                    m_Log.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name + "," + ErrorCol, "失败", "修改", "SysRole");
                    return Json(JsonHandler.CreateMessage(0, Suggestion.EditFail + ErrorCol));
                }
            }
            else
            {
                return Json(JsonHandler.CreateMessage(0, Suggestion.EditFail));
            }
        }
예제 #4
0
        public bool Edit(ref ValidationErrors errors, SysRoleModel model)
        {
            try
            {
                SysRole entity = m_Rep.GetById(model.Id);
                if (entity == null)
                {
                    errors.Add(Suggestion.Disable);
                    return false;
                }
                entity.Id = model.Id;
                entity.Name = model.Name;
                entity.Description = model.Description;
                entity.CreateTime = model.CreateTime;
                entity.CreatePerson = model.CreatePerson;

                if (m_Rep.Edit(entity) == 1)
                {
                    return true;
                }
                else
                {
                    errors.Add(Suggestion.EditFail);
                    return false;
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return false;
            }
        }
예제 #5
0
 public SysRoleModel GetById(string id)
 {
     if (IsExist(id))
     {
         SysRole entity = m_Rep.GetById(id);
         SysRoleModel model = new SysRoleModel();
         model.Id = entity.Id;
         model.Name = entity.Name;
         model.Description = entity.Description;
         model.CreateTime = entity.CreateTime;
         model.CreatePerson = entity.CreatePerson;
         return model;
     }
     else
     {
         return null;
     }
 }