コード例 #1
0
        public async Task <ActionResult <StoreReadDto> > GetStoreById(int id)
        {
            var storeItem = await _repository.GetStoreById(id);

            if (storeItem != null)
            {
                return(Ok(_mapper.Map <StoreReadDto>(storeItem)));
            }
            return(NotFound());
        }
コード例 #2
0
        // GET: LocationsController/Details/5
        public IActionResult Details(int id)
        {
            var    orders    = _orderRepo.GetOrdersByStoreId(id);
            string storeName = _storeRepo.GetStoreById(id).StoreName;

            ViewData["Store"] = storeName;
            List <OrderViewModel> ViewOrders = new List <OrderViewModel>();

            if (orders.Any())
            {
                foreach (var order in orders)
                {
                    string   customerName          = _customerRepo.GetCustomerById(order.GetCustomerId).CustomerFullName;
                    DateTime time                  = order.GetTime;
                    decimal  total                 = order.GetTotal;
                    Dictionary <string, int> items = new Dictionary <string, int>();
                    foreach (var kvp in order.GetOrderItems)
                    {
                        string productName = _productRepo.GetProductById(kvp.Key).ProductName;
                        items[productName] = kvp.Value;
                    }

                    ViewOrders.Add(new OrderViewModel
                    {
                        Id       = order.OrderId,
                        Store    = storeName,
                        Customer = customerName,
                        Time     = time,
                        Total    = total,
                        Products = items
                    });
                }
            }

            _logger.LogInformation("Retrieving store order history from Locations/Details");
            return(View(ViewOrders));
        }
コード例 #3
0
        public IActionResult CheckOut()
        {
            var store = _storeRepo.GetStoreById(_shoppingCart.StoreId);

            foreach (var kvp in _shoppingCart.GetCart())
            {
                if (kvp.Value > store.StoreInventory[kvp.Key])
                {
                    TempData["noStock"] = "true";
                    return(RedirectToAction("Index"));
                }
            }

            TempData["noStock"] = "false";
            return(View());
        }