Esempio n. 1
0
 public static List <Mahsolat> Get()
 {
     try
     {
         using (FruitShopEntity db = new FruitShopEntity())
         {
             return(db.Mahsolats.ToList());
         }
     }
     catch (Exception)
     {
         return(new List <Mahsolat>());
     }
 }
Esempio n. 2
0
 public static Mahsolat Get(int id)
 {
     try
     {
         using (FruitShopEntity db = new FruitShopEntity())
         {
             return(db.Mahsolats.Single(x => x.MahsolatID == id));
         }
     }
     catch (Exception)
     {
         return(new Mahsolat());
     }
 }
Esempio n. 3
0
            public static bool Add(Mahsolat mahsol)
            {
                try
                {
                    using (FruitShopEntity db = new FruitShopEntity())
                    {
                        db.Mahsolats.Add(mahsol);
                        db.SaveChanges();
                    }

                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
Esempio n. 4
0
            public static bool Update(Mahsolat mahsol)
            {
                try
                {
                    using (FruitShopEntity db = new FruitShopEntity())
                    {
                        var model = db.Mahsolats.Single(x => x.MahsolatID == mahsol.MahsolatID);

                        model.Name        = mahsol.Name;
                        model.Description = mahsol.Description;
                        model.OldPrice    = mahsol.OldPrice;
                        model.NewPrice    = mahsol.NewPrice;
                        db.SaveChanges();
                    }

                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }