Esempio 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));
        }
Esempio n. 2
0
        public async Task <IActionResult> GetAll()
        {
            var result = await _supplementService.GetAll();

            if (result == null)
            {
                return(NotFound("Collection is empty!"));
            }
            var response = _mapper.Map <IEnumerable <SupplementsResponse> >(result);

            return(Ok(response));
        }
Esempio n. 3
0
        public ActionResult GetSupplements()
        {
            var supplements = _supplementService.GetAll();

            return(Ok(supplements));
        }