Beispiel #1
0
 public List <productline> GetAllProductLines()
 {
     using (var db = new ToysForBoysEntities())
     {
         return(db.productlines.OrderBy(m => m.name).ToList());
     }
 }
Beispiel #2
0
 public product GetProductById(int?id)
 {
     using (var db = new ToysForBoysEntities())
     {
         var product = db.products.Find(id);
         return(product);
     }
 }
Beispiel #3
0
 public List <country> GetAllCountries()
 {
     using (var db = new ToysForBoysEntities())
     {
         var query = (from countries in db.countries
                      select countries).ToList();
         return(query);
     }
 }
Beispiel #4
0
 public customer GetCustomerByEmail(string email)
 {
     using (var db = new ToysForBoysEntities())
     {
         customer customer = (from custom in db.customers
                              where custom.email == email
                              select custom).FirstOrDefault();
         return(customer);
     }
 }
Beispiel #5
0
 public List <product> GetProductLineDetails(int id)
 {
     using (var db = new ToysForBoysEntities())
     {
         var query = from productLineDetails in db.products.Include("productline")
                     where  productLineDetails.productline.id == id && productLineDetails.buyPrice != 0
                     orderby productLineDetails.name
                     select productLineDetails;
         return(query.ToList());
     }
 }
Beispiel #6
0
        public int CreateNewOrder(order order)
        {
            var neworderid = 0;

            using (var db = new ToysForBoysEntities())
            {
                db.orders.Add(order);
                db.SaveChanges();
                neworderid = order.id;
            }
            return(neworderid);
        }
Beispiel #7
0
 public void AddNewOrderLine(WinkelMandItem winkelMandItem, int orderID)
 {
     using (var db = new ToysForBoysEntities())
     {
         orderdetail newOrderDetail = new orderdetail();
         newOrderDetail.orderId         = orderID;
         newOrderDetail.priceEach       = winkelMandItem.Prijs;
         newOrderDetail.quantityOrdered = winkelMandItem.AantalTeBestellen;
         newOrderDetail.productId       = winkelMandItem.ID;
         db.orderdetails.Add(newOrderDetail);
         db.SaveChanges();
     }
 }
Beispiel #8
0
        public void RegisterCustomer(RegisterViewModel model)
        {
            customer newcustomer = new customer()
            {
                name = model.Name, streetAndNumber = model.StreetAndNr, city = model.City, state = model.State, postalCode = model.PostalCode, countryId = model.CountryID, email = model.Email
            };

            using (var db = new ToysForBoysEntities())
            {
                db.customers.Add(newcustomer);
                db.SaveChanges();
            }
        }
Beispiel #9
0
 public void UpdateAantallenInStock(List <WinkelMandItem> winkelmanditems)
 {
     using (var db = new ToysForBoysEntities())
     {
         foreach (var item in winkelmanditems)
         {
             var product = db.products.Find(item.ID);
             product.quantityInOrder += item.AantalTeBestellen;
             product.quantityInStock -= item.AantalTeBestellen;
             db.SaveChanges();
         }
     }
 }
Beispiel #10
0
 public void changeOrderStatus(int id)
 {
     using (var db = new ToysForBoysEntities())
     {
         order openOrderCustomer = (from order in db.orders
                                    where (order.id == id)
                                    select order).FirstOrDefault();
         if (openOrderCustomer != null)
         {
             openOrderCustomer.status = "ORDERED";
             db.SaveChanges();
         }
     }
 }
Beispiel #11
0
 public void VerwijderOrderLine(WinkelMandItem winkelMandItem, int orderID)
 {
     using (var db = new ToysForBoysEntities())
     {
         orderdetail orderdetail = (from order in db.orderdetails
                                    where (order.orderId == orderID) && (order.productId == winkelMandItem.ID)
                                    select order).FirstOrDefault();
         if (orderdetail != null)
         {
             db.orderdetails.Remove(orderdetail);
             db.SaveChanges();
         }
     }
 }
Beispiel #12
0
 public void UpdateOrderDetailLine(int productId, int OrderId, int aantal)
 {
     using (var db = new ToysForBoysEntities())
     {
         orderdetail orderdetail = (from order in db.orderdetails
                                    where (order.orderId == OrderId) && (order.productId == productId)
                                    select order).FirstOrDefault();
         if (orderdetail != null)
         {
             orderdetail.quantityOrdered = aantal;
             db.SaveChanges();
         }
     }
 }
Beispiel #13
0
        public List <order> getGeplaatsteBestellingenKlant(int customerId)
        {
            List <order> openOrders = new List <order>();

            using (var db = new ToysForBoysEntities())
            {
                List <order> openOrderCustomer = (from order in db.orders
                                                  where (order.customerId == customerId)
                                                  select order).ToList();
                if (openOrderCustomer != null)
                {
                    openOrders = openOrderCustomer;
                }
            }
            return(openOrders);
        }
Beispiel #14
0
        public List <orderdetail> findMANDJEOrders(int id)
        {
            List <orderdetail> mandjeOrderDetails = new List <orderdetail>();

            using (var db = new ToysForBoysEntities())
            {
                order openOrderCustomer = (from order in db.orders
                                           where (order.customerId == id) && (order.status == "MANDJE")
                                           select order).FirstOrDefault();
                if (openOrderCustomer != null)
                {
                    mandjeOrderDetails = (from orderdetails in db.orderdetails
                                          where orderdetails.orderId == openOrderCustomer.id
                                          select orderdetails).ToList();
                }
            }


            return(mandjeOrderDetails);
        }