Exemplo n.º 1
0
 public static List <Mahsolat> Get()
 {
     try
     {
         using (FruitShopEntity db = new FruitShopEntity())
         {
             return(db.Mahsolats.ToList());
         }
     }
     catch (Exception)
     {
         return(new List <Mahsolat>());
     }
 }
Exemplo 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());
     }
 }
Exemplo 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);
                }
            }
Exemplo 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);
                }
            }