Esempio n. 1
0
 public void UpdateShop(ShopEntity shop)
 {
     using (ShopEntityContext db = new ShopEntityContext())
     {
         db.Entry(shop).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 2
0
 /// <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);
     }
 }
Esempio n. 3
0
        public ShopEntity GetShopById(int shopId)
        {
            ShopEntity result = null;

            using (ShopEntityContext db = new ShopEntityContext())
            {
                result = db.Shops.Find(shopId);
            }

            return(result);
        }