コード例 #1
0
        public async Task <ObjectResultModule> YaeherUserRoleByUserID([FromBody] YaeherUserRoleIn YaeherUserRoleInfo)
        {
            if (!Commons.CheckSecret(YaeherUserRoleInfo.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 values = await _yaeherUserRoleService.YaeherUserRoleList(YaeherUserRoleInfo);

            YaeherRoleIn yaeherRoleIn = new YaeherRoleIn();

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

            var UserRoleList = from Role in RoleList join UserAndRole in values
                               on Role.Id equals UserAndRole.RoleID
                               select new { Role.Id, Role.RoleName, Role.Description, UserAndRole.UserID };

            if (UserRoleList.Count() == 0)
            {
                this.ObjectResultModule.StatusCode = 204;
                this.ObjectResultModule.Message    = "NoContent";
                this.ObjectResultModule.Object     = "";
            }
            else
            {
                YaeherUserRoleJSON yaeherUserRoleJSON = new YaeherUserRoleJSON();
                foreach (var UserRoles in UserRoleList)
                {
                    yaeherUserRoleJSON.RoleID += UserRoles.Id + ",";
                    yaeherUserRoleJSON.UserID  = UserRoles.UserID;
                }
                this.ObjectResultModule.Object     = yaeherUserRoleJSON;
                this.ObjectResultModule.StatusCode = 200;
                this.ObjectResultModule.Message    = "success";
            }
            #region 操作日志
            var CreateYaeherOperList = new YaeherOperList()
            {
                OperExplain = "YaeherUserRoleByUserID",
                OperContent = JsonHelper.ToJson(YaeherUserRoleInfo),
                OperType    = "YaeherUserRoleByUserID",
                CreatedBy   = userid,
                CreatedOn   = DateTime.Now
            };
            var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList);

            #endregion
            return(ObjectResultModule);
        }
コード例 #2
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);
        }
コード例 #3
0
        public async Task <ObjectResultModule> YaeherRoleList([FromBody] YaeherRoleIn 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;
            DateTime StartTime = new DateTime();
            DateTime EndTime   = new DateTime();

            if (!string.IsNullOrEmpty(YaeherRoleInfo.StartTime))
            {
                StartTime = DateTime.Parse(YaeherRoleInfo.StartTime);
                if (string.IsNullOrEmpty(YaeherRoleInfo.EndTime))
                {
                    YaeherRoleInfo.EndTime = DateTime.Now.ToString("yyyy-MM-dd");
                }
            }
            if (!string.IsNullOrEmpty(YaeherRoleInfo.EndTime))
            {
                EndTime = DateTime.Parse(YaeherRoleInfo.EndTime);
            }
            if (!string.IsNullOrEmpty(YaeherRoleInfo.StartTime))
            {
                YaeherRoleInfo.AndAlso(t => t.CreatedOn >= StartTime && t.CreatedOn < EndTime.AddDays(+1));
            }
            if (!string.IsNullOrEmpty(YaeherRoleInfo.KeyWord))
            {
                YaeherRoleInfo.AndAlso(t => t.RoleCode.Contains(YaeherRoleInfo.KeyWord) ||
                                       t.RoleName.Contains(YaeherRoleInfo.KeyWord));
            }
            YaeherRoleInfo.AndAlso(a => a.IsDelete == false);
            var values = await _yaeherRoleService.YaeherRoleList(YaeherRoleInfo);

            if (values.Count == 0)
            {
                this.ObjectResultModule.StatusCode = 204;
                this.ObjectResultModule.Message    = "NoContent";
                this.ObjectResultModule.Object     = "";
            }
            else
            {
                this.ObjectResultModule.Object     = values;
                this.ObjectResultModule.StatusCode = 200;
                this.ObjectResultModule.Message    = "success";
            }
            #region 操作日志
            var CreateYaeherOperList = new YaeherOperList()
            {
                OperExplain = "YaeherRoleList",
                OperContent = JsonHelper.ToJson(YaeherRoleInfo),
                OperType    = "YaeherRoleList",
                CreatedBy   = userid,
                CreatedOn   = DateTime.Now
            };
            var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList);

            #endregion
            return(ObjectResultModule);
        }