public void UpdateShop(ShopEntity shop) { using (ShopEntityContext db = new ShopEntityContext()) { db.Entry(shop).State = EntityState.Modified; db.SaveChanges(); } }
/// <summary> /// /// </summary> /// <param name="shop"></param> /// <returns>Id магазина в БД</returns> public int InsertShop(ShopEntity shop) { //TODO: сделать проверку на существующий элемент. В этом случае делать Update using (ShopEntityContext db = new ShopEntityContext()) { ShopEntity insertedShop = db.Shops.Add(shop); db.SaveChanges(); return(insertedShop.Id); } }