public ShopingCartController(IDrink drinkRepository, IShopingCart shopingCartRepository, ICategory categoryRepository, ShopingCard shopingCart)
 {
     _drinkRepository       = drinkRepository;
     _shopingCartRepository = shopingCartRepository;
     _categoryRepository    = categoryRepository;
     _shopingCart           = shopingCart;
 }
Пример #2
0
        public int CreateShopingCard(string id)
        {
            var result = new ShopingCard()
            {
                Quontity = 0,
                Payment  = new List <PaymentCard>(),
                Shippers = this.db.Shippers.FirstOrDefault(),
                UserId   = id
            };

            this.db.Add(result);
            this.db.SaveChanges();
            return(result.Id);
        }
Пример #3
0
 // This method gets called by the runtime. Use this method to add services to the container.
 // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddDbContext <AppDbContext>(options => options.UseSqlServer(_configurationRoot.GetConnectionString("DefaultConnection")));
     services.AddIdentity <IdentityUser, IdentityRole>().AddEntityFrameworkStores <AppDbContext>();
     services.AddTransient <IDrink, DrinkRepository>();
     services.AddTransient <ICategory, CategoryRepository>();
     services.AddTransient <IShopingCart, ShopingCartRepository>();
     services.AddTransient <IOrder, OrderRepository>();
     services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
     services.AddScoped(sp => ShopingCard.GetCart(sp));
     services.AddMvc();
     services.AddMemoryCache();
     services.AddSession();
 }
Пример #4
0
        public void AddToCard(Products product, int amountOfProducts)
        {
            var shopingCard =
                _databaseContext.ShopingCard.SingleOrDefault(s => s.Products.Id == product.Id &&
                                                             s.ShopingCardId == ShoppingCardId);

            if (shopingCard == null)
            {
                shopingCard = new ShopingCard
                {
                    ShopingCardId    = ShoppingCardId,
                    Products         = product,
                    AmountOfProducts = 1
                };

                _databaseContext.ShopingCard.Add(shopingCard);
            }
            else
            {
                shopingCard.AmountOfProducts++;
            }
            _databaseContext.SaveChanges();
        }
        public OrderRepository(AppDbContext appDbContext, ShopingCard shoppingCart)
        {
            _appDbContext = appDbContext;

            _shoppingCart = shoppingCart;
        }
 public ShopingCardSummeryViewComponents(ShopingCard shopingCard)
 {
     _shopingCard = shopingCard;
 }
 public OrderController(IOrder order, ShopingCard shoppingCar)
 {
     _order        = order;
     _shoppingCart = shoppingCar;
 }