Пример #1
0
        public List <StaticRelationConsole> UserStaticConsole(int userId)
        {
            var result = from CP in _context.ConsolePlays
                         join C in _context.Consoles on CP.ConsoleId equals C.Id
                         join U in _context.Users on CP.UserId equals U.Id
                         where CP.UserId == userId
                         select new {
                ConsolePlayId        = CP.Id,
                ConsoleId            = CP.Id,
                ConsoleName          = C.ConsoleName,
                ConsoleNumber        = C.ConsoleNumber,
                ConsoleType          = C.Type,
                ConsoleStandartPrice = C.StandartPrice,
                Gamer         = CP.Gamer,
                Price         = CP.Price,
                isFixedTime   = CP.isFixedTime,
                FixedTime     = CP.FixedTime,
                PauseStart    = CP.PauseStart,
                PauseFinish   = CP.PauseFinish,
                PauseDuration = CP.PauseDuration,
                PlayStart     = CP.PlayStart,
                PlayFinish    = CP.PlayFinish == "Waiting" ? "00:00:00" : CP.PlayFinish,
                Paid          = CP.Paid,
                Sum           = CP.Paid,
                dateDay       = DateTime.Parse(CP.PlayFinish == "Waiting" ? "00:00:00" : CP.PlayFinish).Date,
                date          = CP.PlayFinish == "Waiting" ? "00:00:00" : CP.PlayFinish,
                userId        = CP.UserId,
                OrigUserId    = U.Id,
                UserName      = U.FirstName,
                UserLastName  = U.LastName,
            } into CPtable
            group CPtable by CPtable.dateDay into g
                select new StaticRelationConsole {
                Date      = g.FirstOrDefault().date,
                AboutUser = g.GroupBy(d => d.userId)
                            .Select(
                    d => new AboutUserConsole
                {
                    UserId    = g.First().userId,
                    SumDay    = Math.Round(g.Sum(s => s.Sum), 2),
                    Name      = g.First().UserName,
                    LastName  = g.First().UserLastName,
                    DetailDay = g.GroupBy(DD => DD.date)
                                .Select(DD => new DetailDayConsole {
                        ConsoleId            = DD.First().ConsoleId,
                        ConsoleName          = DD.First().ConsoleName,
                        ConsoleNumber        = DD.First().ConsoleNumber,
                        ConsoleType          = DD.First().ConsoleType,
                        ConsoleStandartPrice = DD.First().ConsoleStandartPrice,
                        PlayStart            = DD.First().PlayStart,
                        PlayFinish           = DD.First().PlayFinish == "Waiting" ? "00:00:00" : DD.First().PlayFinish,
                        Sum = DD.First().Sum,
                    }).ToList()
                }).ToList()
            };


            //return PagedList<StaticRelation>.Create(result,userParams.PageNumber, userParams.PageSize);
            return(result.OrderByDescending(x => DateTime.Parse(x.Date)).ToList());
        }
Пример #2
0
        //public PagedList<StaticRelation> UserStatic(UserParams userParams,int userId)
        public List <StaticRelation> UserStatic(int userId)
        {
            var result = from T in _context.Trades
                         join M in _context.Magazines on T.MagazineId equals M.Id
                         join U in _context.Users on T.UserId equals U.Id
                         where T.UserId == userId
                         select new {
                TradeId         = T.Id,
                TradeQuantity   = T.QuantityProduct,
                ProductId       = M.Id,
                ProductName     = M.Name,
                ProductPrice    = M.Price,
                QuantityProduct = T.QuantityProduct,
                //Sum = M.Price*T.QuantityProduct,
                dateDay      = DateTime.Parse(T.BuyDate).Date,
                date         = T.BuyDate,
                userId       = T.UserId,
                OrigUserId   = U.Id,
                UserName     = U.FirstName,
                UserLastName = U.LastName
            } into Ttable
            group Ttable by Ttable.dateDay into g
                select new StaticRelation {
                Date = g.FirstOrDefault().date,
                // AboutUser = g.Select(x=> new {
                //     toDaySum = x.Sum,
                //     User = x.UserName,
                //     Userlast = x.UserLastName,
                // }).ToList()
                AboutUser = g.GroupBy(d => d.userId)
                            .Select(
                    d => new AboutUser
                {
                    Id        = g.First().userId,
                    SumDay    = g.Sum(s => s.ProductPrice * s.QuantityProduct),
                    Name      = g.First().UserName,
                    LastName  = g.First().UserLastName,
                    DetailDay = g.GroupBy(DD => DD.date)
                                .Select(DD => new DetailDay {
                        ProductId       = DD.First().ProductId,
                        ProductName     = DD.First().ProductName,
                        ProductPrice    = DD.First().ProductPrice,
                        QuantityProduct = DD.First().QuantityProduct,
                        //Sum = DD.First().Sum,
                        DateBuy = DD.First().date
                    }).ToList()
                }).ToList()
            };


            // return PagedList<StaticRelation>.Create(result,userParams.PageNumber, userParams.PageSize);
            return(result.OrderByDescending(x => DateTime.Parse(x.Date)).ToList());
        }