public bool SetShop(ShopDataContract shopDC) { Shop shopEF = new Shop(); shopEF.Name = shopDC.Name; //shopEF.Price = shopDC. Price; try { context.ShopSet.Add(shopEF); context.SaveChanges(); } catch (Exception ex) { throw ex; } return(true); }
public bool UpdateShop(ShopDataContract shopDC) { Shop shopEF = new Shop(); shopEF = context.ShopSet.FirstOrDefault(x => x.Id == shopDC.Id); shopEF.Name = shopDC.Name; //shopEF.Id = shopDC.Id; //shopEF.Price = shopDC. Price; try { //context.ShopSet.Add(shopEF); context.SaveChanges(); } catch (Exception ex) { throw ex; } return(true); }
public List <ShopDataContract> GetShops() { List <ShopDataContract> shops = new List <ShopDataContract>(); List <Shop> shopsTmp = new List <Shop>(); try { shopsTmp = context.ShopSet.ToList(); foreach (var item in shopsTmp) { ShopDataContract shopTmp = new ShopDataContract(); shopTmp.Name = item.Name; shopTmp.Id = item.Id; } } catch (Exception ex) { throw ex; } return(shops); }