Ejemplo n.º 1
0
        public IActionResult Index()
        {
            FitBodyContext context = new FitBodyContext();
            var            details = from supplement in context.Supplements
                                     join orderline in context.OrderLines on supplement.ID equals orderline.SupplementID
                                     select new OrderDetailsModel()
            {
                SupplementName = supplement.SupplementName,
                Price          = orderline.Price,
                Quantity       = orderline.Quantity,
                Id             = orderline.ID,
                Time           = orderline.Time
            };
            AdminIndexViewModel model = new AdminIndexViewModel()
            {
                CustomIdentityContexts = _customIdentityContext.Users.ToList(),
                Supplements            = _supplementService.GetAll(),
                OrderDetailsModels     = details.OrderByDescending(x => x.Name).ThenBy(x => x.Time).ToList(),
                UnitInStock            = _supplementService.GetAllUnitInStock(),
                SaleCount     = _orderLineService.GetAllSaleCount(),
                UserCount     = _customIdentityContext.Users.Count(),
                BlogPostCount = _blogPostService.GetBlogPostCount(),
            };

            return(View(model));
        }