public void InsertProduct(Product product)
 {
     _db.Product.Include(p => p.OrderDetail);
     _db.Product.Include(p => p.ProductRecipe);
     _db.Add(ManualMapper.ManMap(product));
     _db.SaveChanges();
 }
        public List <OrderDetail> GetOrderDetailByOrderHeaderID(int orderHeaderId)
        {
            OrderHeader        orderHeader  = GetOrderByOrderId(orderHeaderId);
            List <OrderDetail> orderDetails = ManualMapper.ManMap(_db.OrderDetail.Where(od => od.OrderId == orderHeaderId)).ToList();

            return(orderDetails);
        }
        public void UpdateCustomer(Customer customer)
        {
            var dACustomer = ManualMapper.ManMap(customer);

            _db.Update(dACustomer);
            _db.SaveChanges();
        }
        public void UpdateAddress(Address address)
        {
            var dAAddress = ManualMapper.ManMap(address);

            _db.Update(dAAddress);
            _db.SaveChanges();
        }
 public void InsertIngredient(Ingredient ingredient)
 {
     _db.Ingredient.Include(i => i.Inventory);
     _db.Ingredient.Include(i => i.ProductRecipe);
     _db.Add(ManualMapper.ManMap(ingredient));
     _db.SaveChanges();
 }
        public void UpdateIngredient(Ingredient ingredient)
        {
            var dAIngredient = ManualMapper.ManMap(ingredient);

            _db.Update(dAIngredient);
            _db.SaveChanges();
        }
        public void UpdateInventory(Inventory inventory)
        {
            var dAInventory = ManualMapper.ManMap(inventory);

            _db.Update(dAInventory);
            _db.SaveChanges();
        }
 public void InsertCustomer(Customer customer)
 {
     //_db.Customer.Include(c => c.OrderHeader);
     //_db.Customer.Include(c => c.Address);
     _db.Add(ManualMapper.ManMap(customer));
     _db.SaveChanges();
 }
        public void UpdateOrderHeader(OrderHeader orderHeader)
        {
            var dAOrderHeader = ManualMapper.ManMap(orderHeader);

            _db.Update(dAOrderHeader);
            _db.SaveChanges();
        }
        public void UpdateOrderDetail(OrderDetail orderDetails)
        {
            var dAOrderDetails = ManualMapper.ManMap(orderDetails);

            _db.Update(dAOrderDetails);
            _db.SaveChanges();
        }
        public void UpdateProduct(Product product)
        {
            var dAProduct = ManualMapper.ManMap(product);

            _db.Update(dAProduct);
            _db.SaveChanges();
        }
        public void UpdateProductRecipe(ProductRecipe productRecipe)
        {
            var dAProductRecipe = ManualMapper.ManMap(productRecipe);

            _db.Update(dAProductRecipe);
            _db.SaveChanges();
        }
        public void UpdateStore(Store store)
        {
            var dAStore = ManualMapper.ManMap(store);

            _db.Update(dAStore);
            _db.SaveChanges();
        }
 public void InsertStore(Store store)
 {
     _db.Store.Include(s => s.Inventory);
     _db.Store.Include(s => s.OrderHeader);
     _db.Add(ManualMapper.ManMap(store));
     _db.SaveChanges();
 }
 public IEnumerable <OrderHeader> GetOrderHistory(int sortOrder)
 {
     if (sortOrder == 1)
     {
         IEnumerable <OrderHeader> orderHistory = ManualMapper.ManMap(_db.OrderHeader);
         return(orderHistory.OrderBy(o => o.OrderDate));
     }
     else if (sortOrder == 2)
     {
         IEnumerable <OrderHeader> orderHistory = ManualMapper.ManMap(_db.OrderHeader);
         return(orderHistory.OrderByDescending(o => o.OrderDate));
     }
     else if (sortOrder == 3)
     {
         IEnumerable <OrderHeader> orderHistory = ManualMapper.ManMap(_db.OrderHeader);
         return(orderHistory.OrderBy(o => o.TotalCost));
     }
     else if (sortOrder == 4)
     {
         IEnumerable <OrderHeader> orderHistory = ManualMapper.ManMap(_db.OrderHeader);
         return(orderHistory.OrderByDescending(o => o.TotalCost));
     }
     else
     {
         // this is the same code a sfor the case "earliest"
         // I am using it as a default, and I will check for valid inputs in the
         // ConsoleApp
         IEnumerable <OrderHeader> orderHistory = ManualMapper.ManMap(_db.OrderHeader);
         return(orderHistory.OrderBy(o => o.OrderDate));
     };
 }
        public Customer SearchCustomerByNameandPassword(string firstname, string lastname, string password)
        {
            // this miplementation does will break if there is no customer in databse wit the given specs.
            // only use this after you have verified with VerifyCustomer()
            DA.Customer customer  = _db.Customer.Where(c => c.FirstName.ToLower() == firstname && c.LastName.ToLower() == lastname && c.CustomerPassword == password).FirstOrDefault();
            Customer    customer1 = ManualMapper.ManMap(customer);

            return(customer1);
        }
        public bool InsertOrderHeader(OrderHeader orderHeader)
        {
            var returnValue = false;

            //IEnumerable<OrderHeader> orderHistory = GetOrderHistoryCustomer(orderHeader.CustomerID).Where(oh => (oh.OrderDate.AddHours(2) > DateTime.Now) && (oh.StoreID == orderHeader.StoreID));
            //if (orderHistory.Count() >= 0)
            //{
            //_db.OrderHeader.Include(oh => oh.OrderDetail);
            _db.Add(ManualMapper.ManMap(orderHeader));
            _db.SaveChanges();
            returnValue = true;
            //}
            return(returnValue);
        }
        List <Customer> IRepository.GetCustomers(params string[] names)
        {
            List <DA.Customer> collectionDACustomers = new List <DA.Customer>();

            foreach (var item in names)
            {
                List <DA.Customer> customersToAdd = _db.Customer.Where(c => c.FirstName == item || c.LastName == item).ToList();
                foreach (var unit in customersToAdd)
                {
                    if (!collectionDACustomers.Contains(unit))
                    {
                        collectionDACustomers.Add(unit);
                    }
                }
            }
            List <Library.Customer> collectionModelCustomers = ManualMapper.ManMap(collectionDACustomers);

            return(collectionModelCustomers);
        }
 public void InsertProductRecipe(ProductRecipe productRecipe)
 {
     _db.Add(ManualMapper.ManMap(productRecipe));
     _db.SaveChanges();
 }
 public IEnumerable <ProductRecipe> GetProductRecipes()
 {
     return(ManualMapper.ManMap(_db.ProductRecipe));
 }
        public IEnumerable <OrderHeader> GetOrderHistoryStore(int store)
        {
            IEnumerable <OrderHeader> orderCollection = ManualMapper.ManMap(_db.OrderHeader);

            return(orderCollection.Where(o => o.StoreID == store));
        }
        public Product GetProductByID(int productId)
        {
            IEnumerable <Product> productCollection = ManualMapper.ManMap(_db.Product);

            return(productCollection.Where(p => p.ProductID == productId).First());
        }
 public IEnumerable <Product> GetProducts()
 {
     return(ManualMapper.ManMap(_db.Product));
 }
 public IEnumerable <Store> GetStores()
 {
     return(ManualMapper.ManMap(_db.Store));
 }
 public void InsertAddress(Address address)
 {
     _db.Add(ManualMapper.ManMap(address));
     _db.SaveChanges();
 }
 public void InsertInventory(Inventory inventory)
 {
     _db.Add(ManualMapper.ManMap(inventory));
     _db.SaveChanges();
 }
 public void InsertOrderDetail(OrderDetail orderDetail)
 {
     _db.Add(ManualMapper.ManMap(orderDetail));
     _db.SaveChanges();
 }
        public IEnumerable <OrderHeader> GetOrderHistoryCustomer(int user)
        {
            IEnumerable <OrderHeader> orderCollection = ManualMapper.ManMap(_db.OrderHeader);

            return(orderCollection.OrderByDescending(o => o.OrderDate).Where(o => o.CustomerID == user));
        }
 public IEnumerable <OrderHeader> GetOrderHeaders()
 {
     return(ManualMapper.ManMap(_db.OrderHeader));
 }
        public IEnumerable <OrderHeader> GetOrderHistoryAddress(int address)
        {
            IEnumerable <OrderHeader> orderCollection = ManualMapper.ManMap(_db.OrderHeader);

            return(orderCollection.Where(o => o.AddressID == address));
        }