コード例 #1
0
 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();
     }
 }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }