public static bool Update(Mahsolat mahsolat) { try { using (FruitShopEntity db = new FruitShopEntity()) { var model = db.Mahsolats.Single(x => x.MahsolatID == mahsolat.MahsolatID); model.Name = mahsolat.Name; model.NewPrice = mahsolat.NewPrice; model.OldPrice = mahsolat.OldPrice; model.Description = mahsolat.Description; model.IsDiscount = mahsolat.IsDiscount; if (!string.IsNullOrEmpty(mahsolat.ImageUrl)) { model.ImageUrl = mahsolat.ImageUrl; } db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public static bool Add(Mahsolat mahsolat) { try { using (FruitShopEntity db = new FruitShopEntity()) { db.Mahsolats.Add(mahsolat); db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public static void Show(GridView gv, HttpSessionState session) { List <Card> list = new List <Card>(); //get from session if (session["CARD"] != null) { list = session["CARD"] as List <Card>; } foreach (var item in list) { item.Mahsol = Mahsolat.Get(item.MahsolatID); } string[] t = new string[1]; t[0] = "MahsolatID"; gv.DataKeyNames = t; gv.DataSource = list; gv.DataBind(); }
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); } }