public BasketFunctions(BasketRepository basketRepo, BasketItemRepository itemsRepo, ProductRepository productRepo, BasketBuilder basketBuilder) { _basketRepo = basketRepo ?? throw new ArgumentNullException(nameof(BasketRepository)); _itemRepo = itemsRepo ?? throw new ArgumentNullException(nameof(BasketRepository)); _productRepo = productRepo ?? throw new ArgumentNullException(nameof(BasketRepository)); _basketBuilder = basketBuilder ?? throw new ArgumentNullException(nameof(BasketRepository)); }
public ShopService(ComputerShopContext context) { productRepo = new ProductRepository(context); categoryRepo = new CategoryRepository(context); basketRepo = new BasketRepository(context); userRepo = new UserRepository(context); basketItemRepo = new BasketItemRepository(context); orderRepo = new OrderRepository(context); addressRepo = new AddressRepository(context); }
// GET: Basket public async Task <IActionResult> Index() { ViewBag.AvailQuantity = new List <SelectListItem> { new SelectListItem { Text = "1", Value = "1" }, new SelectListItem { Text = "2", Value = "2" }, new SelectListItem { Text = "3", Value = "3" } }; string url = "api/basket"; BasketItemRepository BasketRepo = new BasketItemRepository(); HttpClient client = _basketAPI.CreateClient(); HttpResponseMessage response = await client.GetAsync(url); // checking the response is successful or not which is sent using HttpClient if (response.IsSuccessStatusCode) { var result = response.Content.ReadAsStringAsync().Result; BasketRepo.customerBasket = JsonConvert.DeserializeObject <List <BasketHelper> >(result); } if (BasketRepo.customerBasket != null) { var custBasket = BasketRepo.customerBasket; return(View(custBasket)); } else { return(View()); } }
public BasketItemService() { repository = new BasketItemRepository(); }