Beispiel #1
0
        public async Task <ObjectResultModule> DeleteYaeherRole([FromBody]  YaeherRole YaeherRoleInfo)
        {
            if (!Commons.CheckSecret(YaeherRoleInfo.Secret))
            {
                this.ObjectResultModule.StatusCode = 422;
                this.ObjectResultModule.Message    = "Wrong Secret";
                this.ObjectResultModule.Object     = "";
                return(this.ObjectResultModule);
            }
            var userid = _IabpSession.UserId > 0 ? (int)_IabpSession.UserId : 0;
            var query  = await _yaeherRoleService.YaeherRoleByID(YaeherRoleInfo.Id);

            YaeherUserRoleIn yaeherUserRoleIn = new YaeherUserRoleIn();

            yaeherUserRoleIn.AndAlso(a => a.IsDelete == false);
            yaeherUserRoleIn.AndAlso(a => a.RoleID == YaeherRoleInfo.Id);
            var RoleUserList = await _yaeherUserRoleService.YaeherUserRoleList(yaeherUserRoleIn);

            if (RoleUserList.Count() > 0)
            {
                this.ObjectResultModule.Message    = "用户使用角色不可删除!";
                this.ObjectResultModule.StatusCode = 100;
                this.ObjectResultModule.Object     = "";
                return(this.ObjectResultModule);
            }
            if (query != null)
            {
                query.DeleteBy   = userid;
                query.DeleteTime = DateTime.Now;
                query.IsDelete   = true;
                var res = await _yaeherRoleService.DeleteYaeherRole(query);

                this.ObjectResultModule.Object     = res;
                this.ObjectResultModule.Message    = "sucess";
                this.ObjectResultModule.StatusCode = 200;
            }
            else
            {
                this.ObjectResultModule.Message    = "NotFound";
                this.ObjectResultModule.StatusCode = 404;
                this.ObjectResultModule.Object     = "";
            }
            #region 操作日志
            var CreateYaeherOperList = new YaeherOperList()
            {
                OperExplain = "DeleteYaeherRole",
                OperContent = JsonHelper.ToJson(YaeherRoleInfo),
                OperType    = "DeleteYaeherRole",
                CreatedBy   = userid,
                CreatedOn   = DateTime.Now
            };
            var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList);

            #endregion
            return(this.ObjectResultModule);
        }
Beispiel #2
0
        public async Task <ObjectResultModule> UpdateYaeherRole([FromBody]  YaeherRole YaeherRoleInfo)
        {
            if (!Commons.CheckSecret(YaeherRoleInfo.Secret))
            {
                this.ObjectResultModule.StatusCode = 422;
                this.ObjectResultModule.Message    = "Wrong Secret";
                this.ObjectResultModule.Object     = "";
                return(this.ObjectResultModule);
            }
            var userid           = _IabpSession.UserId > 0 ? (int)_IabpSession.UserId : 0;
            var UpdateYaeherRole = await _yaeherRoleService.YaeherRoleByID(YaeherRoleInfo.Id);

            if (UpdateYaeherRole != null)
            {
                UpdateYaeherRole.RoleName    = YaeherRoleInfo.RoleName;
                UpdateYaeherRole.Description = YaeherRoleInfo.Description;
                UpdateYaeherRole.Enabled     = YaeherRoleInfo.Enabled;
                UpdateYaeherRole.IsAdmin     = YaeherRoleInfo.IsAdmin;
                UpdateYaeherRole.RoleCode    = YaeherRoleInfo.RoleCode;
                UpdateYaeherRole.ModifyOn    = DateTime.Now;
                UpdateYaeherRole.ModifyBy    = userid;
                var result = await _yaeherRoleService.UpdateYaeherRole(UpdateYaeherRole);

                this.ObjectResultModule.Object     = result;
                this.ObjectResultModule.StatusCode = 200;
                this.ObjectResultModule.Message    = "success";
            }
            else
            {
                this.ObjectResultModule.Object     = "";
                this.ObjectResultModule.StatusCode = 404;
                this.ObjectResultModule.Message    = "NotFound";
            }
            #region 操作日志
            var CreateYaeherOperList = new YaeherOperList()
            {
                OperExplain = "UpdateYaeherRole",
                OperContent = JsonHelper.ToJson(YaeherRoleInfo),
                OperType    = "UpdateYaeherRole",
                CreatedBy   = userid,
                CreatedOn   = DateTime.Now
            };
            var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList);

            #endregion
            return(ObjectResultModule);
        }
Beispiel #3
0
        public async Task <ObjectResultModule> CreateYaeherRole([FromBody] YaeherRole YaeherRoleInfo)
        {
            if (!Commons.CheckSecret(YaeherRoleInfo.Secret))
            {
                this.ObjectResultModule.StatusCode = 422;
                this.ObjectResultModule.Message    = "Wrong Secret";
                this.ObjectResultModule.Object     = "";
                return(this.ObjectResultModule);
            }
            var          userid       = _IabpSession.UserId > 0 ? (int)_IabpSession.UserId : 0;
            YaeherRoleIn yaeherRoleIn = new YaeherRoleIn();

            yaeherRoleIn.AndAlso(a => a.IsDelete == false);
            yaeherRoleIn.AndAlso(a => a.RoleCode == YaeherRoleInfo.RoleCode && a.RoleName == YaeherRoleInfo.RoleName);
            var RoleList = await _yaeherRoleService.YaeherRoleList(yaeherRoleIn);

            if (RoleList.Count() > 0)
            {
                this.ObjectResultModule.Object     = "";
                this.ObjectResultModule.StatusCode = 100;
                this.ObjectResultModule.Message    = "角色重复!";
                return(ObjectResultModule);
            }
            var CreateYaeherRole = new YaeherRole()
            {
                RoleName    = YaeherRoleInfo.RoleName,
                Description = YaeherRoleInfo.Description,
                Enabled     = YaeherRoleInfo.Enabled,
                IsAdmin     = YaeherRoleInfo.IsAdmin,
                RoleCode    = YaeherRoleInfo.RoleCode,
                CreatedBy   = userid,
                CreatedOn   = DateTime.Now
            };
            var result = await _yaeherRoleService.CreateYaeherRole(CreateYaeherRole);

            if (result.Id > 0)
            {
                this.ObjectResultModule.Object     = result;
                this.ObjectResultModule.StatusCode = 200;
                this.ObjectResultModule.Message    = "success";
            }
            else
            {
                this.ObjectResultModule.Object     = "";
                this.ObjectResultModule.StatusCode = 400;
                this.ObjectResultModule.Message    = "error!";
            }
            #region 操作日志
            var CreateYaeherOperList = new YaeherOperList()
            {
                OperExplain = "CreateYaeherRole",
                OperContent = JsonHelper.ToJson(YaeherRoleInfo),
                OperType    = "CreateYaeherRole",
                CreatedBy   = userid,
                CreatedOn   = DateTime.Now
            };
            var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList);

            #endregion
            return(ObjectResultModule);
        }
 public async Task <YaeherRole> UpdateYaeherRole(YaeherRole YaeherRoleInfo)
 {
     return(await _repository.UpdateAsync(YaeherRoleInfo));
 }
        public async Task <YaeherRole> CreateYaeherRole(YaeherRole YaeherRoleInfo)
        {
            YaeherRoleInfo.Id = await _repository.InsertAndGetIdAsync(YaeherRoleInfo);

            return(YaeherRoleInfo);
        }