public void DeleteShop(int id) { Models.DBObjects.Shop shopToDelete = dbContext.Shops.FirstOrDefault(x => x.ShopId == id); if (shopToDelete != null) { dbContext.Shops.DeleteOnSubmit(shopToDelete); dbContext.SubmitChanges(); } }
public void UpdateShop(ShopModel shopModel) { Models.DBObjects.Shop existingShop = dbContext.Shops.FirstOrDefault(x => x.ShopId == shopModel.ShopId); if (existingShop != null) { existingShop.ShopId = shopModel.ShopId; existingShop.AddressID = shopModel.AddressID; existingShop.Name = shopModel.Name; existingShop.Phone = shopModel.Phone; existingShop.Email = shopModel.Email; existingShop.CategoryID = shopModel.CategoryID; dbContext.SubmitChanges(); } }
private Models.DBObjects.Shop MapModelToDbObject(ShopModel shopModel) { Models.DBObjects.Shop dbShopModel = new Models.DBObjects.Shop(); if (shopModel != null) { dbShopModel.ShopId = shopModel.ShopId; dbShopModel.AddressID = shopModel.AddressID; dbShopModel.Name = shopModel.Name; dbShopModel.Phone = shopModel.Phone; dbShopModel.Email = shopModel.Email; dbShopModel.CategoryID = shopModel.CategoryID; return(dbShopModel); } return(null); }
private ShopModel MapDbObjectToModel(Models.DBObjects.Shop dbShop) { ShopModel shopModel = new ShopModel(); if (dbShop != null) { shopModel.ShopId = dbShop.ShopId; shopModel.AddressID = dbShop.AddressID; shopModel.Name = dbShop.Name; shopModel.Phone = dbShop.Phone; shopModel.Email = dbShop.Email; shopModel.CategoryID = dbShop.CategoryID; return(shopModel); } return(null); }