public void UpdateShop(Shop pre_shop, Shop current_shop) { using (var db = new IceCreamDB()) { var query = from m in db.IceCreams select m; IEnumerable <IceCream> iceCreams = query.ToList <IceCream>().Where(x => x.ShopId == current_shop.Id); foreach (var iceCream in iceCreams) { db.IceCreams.Attach(iceCream); db.IceCreams.Remove(iceCream); } if (pre_shop != null)//if we get user from main it means he is saved in db.. { db.Shops.Attach(pre_shop); db.Shops.Remove(pre_shop); db.SaveChanges(); } db.Shops.Add(current_shop); db.SaveChanges(); foreach (var iceCream in iceCreams) { db.IceCreams.Add(iceCream); } db.SaveChanges(); } }
public void SaveShop(Shop s) { using (var db = new IceCreamDB()) { db.Shops.Add(s); db.SaveChanges(); } }
public void AddIceCream(IceCream i) { using (var db = new IceCreamDB()) { db.IceCreams.Add(i); db.SaveChanges(); } }
public IceCream FindIceCream(string ID, string ShopId) { using (var db = new IceCreamDB()) { var query = from m in db.IceCreams where m.Id == ID && m.ShopId == ShopId select m; return(query.FirstOrDefault <IceCream>()); } }
public IEnumerable <IceCream> GetIceCreamFromShop(string shopid) { using (var db = new IceCreamDB()) { var list = from i in db.IceCreams where i.ShopId == shopid select i; return(list.ToList <IceCream>()); } }
public IEnumerable <IceCream> FindListIceCream(string taste, string ShopID) { using (var db = new IceCreamDB()) { var query = from m in db.IceCreams where m.Taste.Contains(taste) && m.ShopId == ShopID select m; return(query); } }
public void DeleteIceCream(IceCream iceCream) { using (var db = new IceCreamDB()) { if (iceCream != null) { db.IceCreams.Attach(iceCream); db.IceCreams.Remove(iceCream); db.SaveChanges(); } } }
public bool CheckShop(int id, string password) { using (var db = new IceCreamDB()) { var query = from m in db.Shops where (m.ID == id && m.Password == password) select m; foreach (var item in query) { return(true);//if we entered here there are items in query,user exist } return(false); } }
public IEnumerable <IceCream> GetAllIceCream(Func <IceCream, bool> predicate = null) { using (var db = new IceCreamDB()) { if (predicate == null) { return(db.IceCreams.ToList <IceCream>()); } return((IEnumerable <IceCream>) from s in db.IceCreams where (predicate(s)) select s); } }
public void UpdateIceCream(IceCream pre_IC, IceCream current_IC) { using (var db = new IceCreamDB()) { if (pre_IC != null) { db.IceCreams.Attach(pre_IC); db.IceCreams.Remove(pre_IC); db.SaveChanges(); } db.IceCreams.Add(current_IC); db.SaveChanges(); } }
public Shop findShopByLogin(String id, string password) { using (var db = new IceCreamDB()) { var query = from m in db.Shops where m.Id == id && m.Password == password select m; foreach (var item in query) { return(item);//if we entered here there are items in query,user exist } return(null); } }
public IEnumerable <Shop> GetAllShop(Func <Shop, bool> predicate = null) { using (var db = new IceCreamDB()) { if (predicate == null) { return(db.Shops.ToList <Shop>()); } return((IEnumerable <Shop>) from s in db.Shops where (predicate(s)) select s); } }
public bool CheckShop(string id) { using (var db = new IceCreamDB()) { var query = from m in db.Shops where m.Id == id select m; foreach (var item in query) { return(true);//if we entered here there are items in query,user exist } return(false); } }
public bool CheckIceCream(string ID, string ShopID) { using (var db = new IceCreamDB()) { var query = from m in db.IceCreams where m.Id == ID && m.ShopId == ShopID select m; foreach (var item in query) { return(true); } } return(false); }
public IEnumerable <IceCream> FindListIceCream(string taste, double energy, double calories, double proteins, double medianmark) { using (var db = new IceCreamDB()) { var query = from m in db.IceCreams where (energy <= (m.Energy + 30) && energy >= m.Energy - 30) // (!(energy > (m.Energy + 30)) || ! (energy < (m.Energy - 30))) && ((calories <= (m.Calories + 5)) && calories >= (m.Calories - 5)) && ((proteins <= (m.Proteins + 2)) && proteins >= (m.Proteins - 2)) select m; return(query.ToList <IceCream>().Where(x => Taste(x.Taste).Contains(taste) && !(Median(x) < medianmark - 1))); // .Where(x => !(Median(x) < medianmark - 1)) } }
public void AddShop(Shop s) { var db = new IceCreamDB(); db.Shops.Add(s); db.SaveChanges(); /* try * { * using (var db = new IceCreamDB()) * { * db.Shops.Add(s); * db.SaveChanges(); * } * } * catch (Exception e) * { * throw new Exception("Erreur"); * } */ }