Beispiel #1
0
 public void DeleteFridgeProducts(int id_fridge, int id_product, int amount)
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         Product_Fridge fridge_product = context.Product_Fridge.FirstOrDefault(r => (r.id_fr == id_fridge) && (r.id_pr == id_product));
         int?           currentamount  = fridge_product.amount;
         currentamount         = currentamount - amount;
         fridge_product.amount = currentamount;
         context.SaveChanges();
     }
 }
Beispiel #2
0
 private bool DoesProductInFridgeExists(int id_fridge, int id_product)
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         Product_Fridge fridge_product = context.Product_Fridge.FirstOrDefault(r => (r.id_fr == id_fridge) && (r.id_pr == id_product));
         if (fridge_product != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Beispiel #3
0
 public bool IsEnoughAmountInFridge(int id_fridge, int id_product, int amount)
 {
     using (hotelDBEntities context = new hotelDBEntities())
     {
         Product_Fridge fridge_product = context.Product_Fridge.FirstOrDefault(r => (r.id_fr == id_fridge) && (r.id_pr == id_product));
         if (fridge_product == null) // Pokud produkt neexistuje
         {
             return(false);
         }
         int?currentamount = fridge_product.amount;  // Pokud existuje, zkontruji zda je dostatek amountu
         if (currentamount >= amount)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }