Exemplo n.º 1
0
 public void UpdateProduct(ProductModel productModel)
 {
     using (var context = new WebShopContext())
     {
         try
         {
             // context.ProductModel.Attach(productModel);
             context.Entry(productModel).State = EntityState.Modified;
             context.SaveChanges();
         }
         catch (Exception ex)
         {
             throw;
         }
     }
 }
Exemplo n.º 2
0
 public void UpdateRecipe(RecipesModel recipesModel)
 {
     using (var context = new WebShopContext())
     {
         var result = context.RecipesModel.SingleOrDefault(b => b.RecipeId == recipesModel.RecipeId);
         if (result != null)
         {
             try
             {
                 context.RecipesModel.Attach(recipesModel);
                 context.Entry(recipesModel).State = EntityState.Modified;
                 context.SaveChanges();
             }
             catch (Exception ex)
             {
                 throw;
             }
         }
     }
 }
Exemplo n.º 3
0
 public void UpdateCategory(CategoriesModel categoriesModel)
 {
     using (var context = new WebShopContext())
     {
         var result = context.CategoriesModel.SingleOrDefault(b => b.CategoryId == categoriesModel.CategoryId);
         if (result != null)
         {
             try
             {
                 context.CategoriesModel.Attach(categoriesModel);
                 context.Entry(categoriesModel).State = EntityState.Modified;
                 context.SaveChanges();
             }
             catch (Exception ex)
             {
                 throw ex;
             }
         }
     }
 }
Exemplo n.º 4
0
 public void UpdateBrand(BrandsModel brandsModel)
 {
     using (var context = new WebShopContext())
     {
         var result = context.BrandsModel.SingleOrDefault(b => b.BrandId == brandsModel.BrandId);
         if (result != null)
         {
             try
             {
                 context.BrandsModel.Attach(brandsModel);
                 context.Entry(brandsModel).State = EntityState.Modified;
                 context.SaveChanges();
             }
             catch (Exception ex)
             {
                 throw;
             }
         }
     }
 }
Exemplo n.º 5
0
 public void UpdateOrder(OrdersModel ordersModel)
 {
     using (var context = new WebShopContext())
     {
         var result = context.OrdersModel.SingleOrDefault(b => b.OrderId == ordersModel.OrderId);
         if (result != null)
         {
             try
             {
                 context.OrdersModel.Attach(ordersModel);
                 context.Entry(ordersModel).State = EntityState.Modified;
                 context.SaveChanges();
             }
             catch (Exception ex)
             {
                 throw;
             }
         }
     }
 }