示例#1
0
        public IPagedList <RankDto> Read(int currentPage, int pageSize, bool isParentOnly = false, string searchString = "")
        {
            var data = _repoRank.Read(a => !a.IsDeleted);

            //if (isParentOnly)
            //{
            //    data = data.Where(a => a.GroupId == null);
            //}
            //else
            //{
            //    data = data.Where(a => a.GroupId != null);
            //}

            if (!string.IsNullOrEmpty(searchString))
            {
                data = data.Where(a => a.RankName.Contains(searchString));
            }

            IPagedList <RankDto> result = data.OrderBy(a => a.RankName).Select(a => new RankDto()
            {
                Id          = a.Id,
                CreatedDate = a.CreatedDate,
                RankName    = a.RankName,
                RankImage   = a.RankImage,
                UpdatedDate = a.UpdatedDate
            }).ToPagedList(currentPage, pageSize);

            return(result);
        }
 public AccountDto Edit(int accountId)
 {
     if (accountId > 0)
     {
         var accountDto = Mapper.Map <AccountDto>(_repoAccount.Read(a => true)
                                                  .Include(a => a.Champions)
                                                  .Include(a => a.Skins)
                                                  .Include(a => a.NumberOfPageGems)
                                                  .SingleOrDefault(a => a.Id == accountId));
         return(accountDto);
     }
     return(null);
 }
示例#3
0
        public IPagedList <UserDto> Read(int currentIndex, int pageSize, string searchString = "")
        {
            var query = _userRepositories.Read(a => true);

            if (!string.IsNullOrEmpty(searchString))
            {
                query = query.Where(a => a.GeneralUser.UserName.Contains(searchString));
            }
            var result = query
                         .Include(a => a.GeneralUser)
                         .Select(a => new UserDto()
            {
                Email         = a.GeneralUser.Email,
                Id            = a.Id,
                Balance       = a.Balance,
                CreatedDate   = a.CreatedDate,
                GeneralUserId = a.GeneralUserId,
                IsActive      = a.IsActive,
                UserName      = a.GeneralUser.UserName,
                Point         = a.Point
            }).OrderByDescending(a => a.CreatedDate)
                         .ToPagedList(currentIndex, pageSize);

            return(result);
        }
示例#4
0
        public IPagedList <LuckyWheelHistoryDto> ReadLuckyWheelHistory(int currentIndex, int pageSize, string generalUserId)
        {
            var result = _luckyWheelHistoryRepositories.Read(a => a.User.GeneralUserId == generalUserId)
                         .OrderByDescending(a => a.CreatedDate)
                         .Include(a => a.User)
                         .Include(a => a.User.GeneralUser)
                         .Select(a => new LuckyWheelHistoryDto()
            {
                Id          = a.Id,
                CreatedDate = a.CreatedDate,
                UpdatedDate = a.UpdatedDate,
                NameDisplay = a.User.NameDisplay,
                Result      = a.Result
            }).ToPagedList(currentIndex, pageSize);

            return(result);
        }
示例#5
0
        public IPagedList <LuckyWheelItemDto> ReadLuckyWheelItem(int currentIndex, int pageSize)
        {
            var result = _luckyWheelItemRepositories.Read(a => true)
                         .OrderByDescending(a => a.CreatedDate)
                         .ThenByDescending(a => a.DisplayName)
                         .Select(a => new LuckyWheelItemDto()
            {
                CreatedDate    = a.CreatedDate,
                ImageUrl       = a.ImageUrl,
                Id             = a.Id,
                Description    = a.Description,
                UpdatedDate    = a.UpdatedDate,
                DisplayName    = a.DisplayName,
                WinningPercent = a.WinningPercent,
                IsUnlucky      = a.IsUnlucky
            }).ToPagedList(currentIndex, pageSize);

            return(result);
        }
示例#6
0
        public IPagedList <UserTradingHistoryDto> ReadTradingHistories(string generalUserId, int currentIndex, int pageSize)
        {
            var result = _tradingRepositories.Read(a => a.User.GeneralUserId == generalUserId)
                         .Include(a => a.User)
                         .Include(a => a.Account)
                         .Include(a => a.Account.Rank)
                         .OrderByDescending(a => a.CreatedDate)
                         .Select(a => new UserTradingHistoryDto()
            {
                UserName       = a.User.GeneralUser.UserName,
                PriceOfAccount = a.Account.Price,
                CreatedDate    = a.CreatedDate,
                AccountId      = a.AccountId,
                AccountName    = a.Account.UserName,
                Password       = a.Account.Password,
                RankName       = a.Account.Rank.RankName,
                UserId         = a.UserId
            }).ToPagedList(currentIndex, pageSize);

            return(result);
        }
示例#7
0
        public IPagedList <UserRechargeHistoryDto> ReadRechargeHistories(string generalUserId, int currentIndex, int pageSize)
        {
            var result =
                _rechargeRepositories.Read(a => a.User.GeneralUserId == generalUserId)
                .Include(a => a.User)
                .OrderByDescending(a => a.CreatedDate)
                .Select(a => new UserRechargeHistoryDto()
            {
                Id           = a.Id,
                UserId       = a.UserId,
                CreatedDate  = a.CreatedDate,
                SerialNumber = a.SerialNumber,
                Message      = a.Message,
                ParValue     = a.ParValue,
                PinNumber    = a.PinNumber,
                UpdatedDate  = a.UpdatedDate
            })
                .ToPagedList(currentIndex, pageSize);

            return(result);
        }
示例#8
0
        public IPagedList <ChampionDto> ReadChamp(int currentIndex, int pageSize, string searchString = "")
        {
            var query = _champRepositories.Read(a => !a.IsDeleted);

            if (!string.IsNullOrEmpty(searchString))
            {
                query = query.Where(a => a.ChampionName.Contains(searchString));
            }
            var result = query
                         .OrderBy(a => a.ChampionName)
                         .Select(a => new ChampionDto()
            {
                CreatedDate  = a.CreatedDate,
                Id           = a.Id,
                IsDeleted    = a.IsDeleted,
                ChampionName = a.ChampionName,
                Avatar       = a.Avatar,
                UpdatedDate  = a.UpdatedDate
            }).ToPagedList(currentIndex, pageSize);

            return(result);
        }
示例#9
0
        public int DeletePageGemByAccountId(int accountId)
        {
            var imagesDeleted = _pageGemRepositories.Read(a => a.AccountId == accountId).Select(a => a.ImageUrl);

            _pageGemRepositories.Delete(a => a.AccountId == accountId);
            int result = _pageGemRepositories.SaveChanges();

            if (result > 0)
            {
                foreach (var img in imagesDeleted)
                {
                    FileUlti.DeleteFile(img);
                }
            }

            return(result);
        }
示例#10
0
        public UserTradingHistoryDto Create(UserTradingHistoryDto tradingHistory)
        {
            var data    = Mapper.Map <UserTradingHistory>(tradingHistory);
            var existed = _tradingHistory.Read(a => a.AccountId == data.AccountId).Any();

            if (existed)
            {
                _tradingHistory.Delete(a => a.AccountId == data.AccountId);
            }

            var result = _tradingHistory.Create(data);

            if (_tradingHistory.SaveChanges() > 0)
            {
                return(Mapper.Map <UserTradingHistoryDto>(result));
            }
            return(null);
        }
示例#11
0
        public IPagedList <UserRechargeHistoryDto> ReadRechargeHistories(int currentIndex, int pageSize, int month)
        {
            if (month == 0)
            {
                var result =
                    _rechargeRepositories.Read(a => true)
                    .Include(a => a.User)
                    .OrderByDescending(a => a.CreatedDate)
                    .ThenBy(a => a.UserId)
                    .Select(a => new UserRechargeHistoryDto()
                {
                    Id           = a.Id,
                    UserId       = a.UserId,
                    CreatedDate  = a.CreatedDate,
                    SerialNumber = a.SerialNumber,
                    Message      = a.Message,
                    ParValue     = a.ParValue,
                    PinNumber    = a.PinNumber,
                    UpdatedDate  = a.UpdatedDate,
                    Email        = a.User.GeneralUser.UserName,
                    CardType     = a.CardType
                })
                    .ToPagedList(currentIndex, pageSize);

                return(result);
            }

            var resultRp = _repoUser.Read(a => a.IsActive && a.UserRechargeHistories.Any(b => b.CreatedDate.Month == month && b.CreatedDate.Year == DateTime.Now.Year))
                           .Include(a => a.UserRechargeHistories)
                           .OrderByDescending(a => a.UserRechargeHistories.Where(b => b.CreatedDate.Month == month && b.CreatedDate.Year == DateTime.Now.Year)
                                              .Sum(b => b.ParValue))
                           .Select(a => new UserRechargeHistoryDto()
            {
                UserId      = a.Id,
                ParValue    = a.UserRechargeHistories.Where(b => b.CreatedDate.Month == month && b.CreatedDate.Year == DateTime.Now.Year).Sum(b => b.ParValue),
                Email       = a.GeneralUser.UserName,
                CreatedDate = a.UserRechargeHistories.OrderByDescending(b => b.CreatedDate).FirstOrDefault().CreatedDate
            })
                           .ToPagedList(currentIndex, pageSize);

            return(resultRp);
        }
示例#12
0
        public IList <AccountDto> ReadAccountBySamePrice(float price, IList <int> ignoreId = null)
        {
            var query = _repoAccount.Read(a => a.IsAvailable && (a.Price == price));

            if (ignoreId != null)
            {
                query = query.Where(a => !ignoreId.Contains(a.Id));
            }

            var result = query
                         .Include(a => a.NumberOfPageGems)
                         .Include(a => a.Skins)
                         .Include(a => a.Champions)
                         .Select(a => new AccountDto()
            {
                CreatedDate     = a.CreatedDate,
                RankId          = a.RankId,
                RankName        = a.Rank.RankName,
                UserName        = a.UserName,
                Avatar          = a.Avatar,
                IsAvailable     = a.IsAvailable,
                Description     = a.Description,
                Id              = a.Id,
                IsHot           = a.IsHot,
                Password        = a.Password,
                Price           = a.Price,
                Title           = a.Title,
                UpdatedDate     = a.UpdatedDate,
                NumberOfPageGem = a.NumberOfPageGems.Count,
                NumberOfChamps  = a.Champions.Count,
                NumberOfSkins   = a.Skins.Count
            })
                         .OrderBy(a => a.IsHot)
                         .ThenByDescending(a => a.CreatedDate)
                         .Take(4).ToList();

            return(result);
        }
示例#13
0
 public IList <SkinDto> ReadSkinForFilter()
 {
     return(Mapper.Map <IList <SkinDto> >(_repoSkin.Read(a => !a.IsDeleted)));
 }
示例#14
0
 public IList <RankDto> ReadRankForFilter()
 {
     return(Mapper.Map <IList <RankDto> >(_repoGank.Read(a => !a.IsDeleted)));
 }