예제 #1
0
 /// <summary>
 /// 输出模型
 /// </summary>
 /// <param name="YaeherRoleDto"></param>
 /// <param name="YaeherRoleInfo"></param>
 public YaeherRoleOut(PagedResultDto <YaeherRole> YaeherRoleDto, YaeherRoleIn YaeherRoleInfo)
 {
     Items          = YaeherRoleDto.Items;
     TotalCount     = YaeherRoleDto.TotalCount;
     TotalPage      = YaeherRoleDto.TotalCount / YaeherRoleInfo.MaxResultCount;
     SkipCount      = YaeherRoleInfo.SkipCount;
     MaxResultCount = YaeherRoleInfo.MaxResultCount;
 }
예제 #2
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);
        }
예제 #3
0
        public async Task <PagedResultDto <YaeherRole> > YaeherRolePage(YaeherRoleIn YaeherRoleInfo)
        {
            //初步过滤
            var query = _repository.GetAll().Where(YaeherRoleInfo.Expression).OrderByDescending(a => a.CreatedOn);
            //获取总数
            var tasksCount = query.Count();
            //获取总数
            var totalpage      = tasksCount / YaeherRoleInfo.MaxResultCount;
            var YaeherRoleList = await query.PageBy(YaeherRoleInfo.SkipTotal, YaeherRoleInfo.MaxResultCount).ToListAsync();

            return(new PagedResultDto <YaeherRole>(tasksCount, YaeherRoleList.MapTo <List <YaeherRole> >()));
        }
예제 #4
0
        public async Task <ObjectResultModule> YaeherRoleById([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;
            var values = await _yaeherRoleService.YaeherRoleByID(YaeherRoleInfo.Id);

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

            #endregion
            return(ObjectResultModule);
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
0
        public async Task <IList <YaeherRole> > YaeherRoleList(YaeherRoleIn YaeherRoleInfo)
        {
            var query = _repository.GetAll().Where(YaeherRoleInfo.Expression).OrderByDescending(a => a.CreatedOn);

            return(await query.ToListAsync());
        }