public static void AddWines(Wine wine)//This is Add method.
 {
     try
     {
         using (WineShopEntities db = new WineShopEntities())
         {
             db.Wines.Add(wine);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #2
0
 public static void SaveCustomers(Customer Obj_Customer_Save)//This is Add method.
 {
     try
     {
         using (WineShopEntities db = new WineShopEntities())
         {
             db.Customers.Add(Obj_Customer_Save);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #3
0
 public static void AddRateLists(RateList rateList)//Add method.
 {
     try
     {
         using (WineShopEntities db = new WineShopEntities())
         {
             db.RateLists.Add(rateList);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static void AddCustomers(Customer customer)//Add method.
 {
     try
     {
         using (WineShopEntities db = new WineShopEntities())
         {
             db.Customers.Add(customer);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #5
0
 public static void SaveRateLists(RateList Obj_RateList_Save)//This is Add method.
 {
     try
     {
         using (WineShopEntities db = new WineShopEntities())
         {
             db.RateLists.Add(Obj_RateList_Save);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #6
0
 public static int UpdateRateList(RateList rateList)
 {
     try
     {
         using (WineShopEntities db = new WineShopEntities())
         {
             //Lambda expression
             RateList r = db.RateLists.SingleOrDefault(x => x.ID == rateList.ID);
             r.Price = rateList.Price;
             db.SaveChanges();
             return(rateList.ID);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #7
0
        public static int UpdateWine(Wine Obj_Wine_Update)
        {
            try
            {
                using (WineShopEntities db = new WineShopEntities())
                {
                    //Lambda expression

                    Wine c = db.Wines.SingleOrDefault(x => x.ID == Obj_Wine_Update.ID);
                    c.Name = Obj_Wine_Update.Name;
                    db.SaveChanges();
                    return(Obj_Wine_Update.ID);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public static void DeleteWine(string wineID)
 {
     try
     {
         using (WineShopEntities db = new WineShopEntities())
         {
             //Lambda expression
             Wine w = db.Wines.SingleOrDefault(x => x.ID.ToString().Trim() == wineID.Trim());
             if (w != null)
             {
                 db.Wines.Remove(w);
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #9
0
 public static void DeleteRateList(string rateListID)
 {
     try
     {
         using (WineShopEntities db = new WineShopEntities())
         {
             //Lambda expression
             RateList r = db.RateLists.SingleOrDefault(x => x.ID.ToString().Trim() == rateListID.Trim());
             if (r != null)
             {
                 db.RateLists.Remove(r);
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #10
0
 public static void DeleteCustomer(string Obj_Customer_Delete)
 {
     try
     {
         using (WineShopEntities db = new WineShopEntities())
         {
             //Lambda expression
             Customer c = db.Customers.SingleOrDefault(x => x.ID.ToString().Trim() == Obj_Customer_Delete.Trim());
             if (c != null)
             {
                 db.Customers.Remove(c);
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #11
0
 public static int UpdateCustomer(Customer Obj_Customer_Update)
 {
     try
     {
         using (WineShopEntities db = new WineShopEntities())
         {
             //Lambda expression
             Customer c = db.Customers.SingleOrDefault(x => x.ID == Obj_Customer_Update.ID);
             c.Name       = Obj_Customer_Update.Name;
             c.Age        = Obj_Customer_Update.Age;
             c.Email      = Obj_Customer_Update.Email;
             c.RateListID = Obj_Customer_Update.RateListID;
             c.WineID     = Obj_Customer_Update.WineID;
             db.SaveChanges();
             return(Obj_Customer_Update.ID);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }