Exemplo n.º 1
0
        void Istoreinventory.Updateinventory(string store_phonenumber, string product, int quantity)
        {
            Store storequery = _context.Stores.Where(x => x.StorePhoneNumber.Equals(store_phonenumber)).First();

            Models.Product newproduct = new Models.Product();


            Product productquery = _context.Products.Where(x => x.ProductName.Equals(product)).First();

            StoreInventory storeInventory = _context.StoreInventories.FirstOrDefault(x => x.StoreId.Equals(storequery.Id) && x.ProductId == productquery.Id);

            if (storeInventory == null)
            {
                StoreInventory storei = new StoreInventory();
                storei.ProductId       = productquery.Id;
                storei.ProductQuantity = quantity;
                storei.StoreId         = storequery.Id;

                _context.Add(storei);
                _context.SaveChanges();
            }
            else
            {
                storeInventory.ProductQuantity = quantity;
                _context.Update(storeInventory);
                _context.SaveChanges();
            }
        }
        int IOrder.AddOrder(Models.Order customerorder)
        {
            var   AddOrder = _context.Orders.OrderBy(x => x.Id).Last();
            Order neworder = new Order();

            neworder.CustomerId = customerorder.CustomerID;
            neworder.DatePlaced = (DateTime)customerorder.Date;
            neworder.StoreId    = customerorder.StoreID;

            _context.Add(neworder);

            _context.SaveChanges();

            return(neworder.Id);
        }
        void IProduct.AddProduct(Models.Product product)
        {
            var newproduct = new Product()
            {
                ProductName        = product.ProductName,
                ProductPrice       = product.ProductPrice,
                ProductDescription = product.ProductDescription
            };

            _context.Add(newproduct);

            _context.SaveChanges();
        }
        public void AddCustomer(User customer)
        {
            var newCustomer = new Member()
            {
                FirstName = customer.FirstName,
                LastName  = customer.LastName,
                Role      = customer.Role,
                Email     = customer.Email,
                Password  = customer.Password
            };

            _context.Add(newCustomer);

            _context.SaveChanges();
        }
Exemplo n.º 5
0
        public void AddStore(Models.Store store)
        {
            Store newstore = new Store()
            {
                StoreName            = "ElectoBuy",
                StoreLocationAddress = store.StoreLocationAddress,
                StoreLocationCity    = store.StoreLocationCity,
                StoreLocationState   = store.StoreLocationState,
                StoreLocationCountry = store.StoreLocationCountry,
                StoreLocationZip     = store.StoreLocationZip,
                StorePhoneNumber     = store.StorePhoneNumber,
            };

            _context.Add(newstore);
            _context.SaveChanges();
        }