Example #1
0
 public void Insert(ProviderBindingModel model)
 {
     using (var context = new TechiqueShopDatabase())
     {
         context.Providers.Add(CreateModel(model, new Provider()));
         context.SaveChanges();
     }
 }
Example #2
0
 public void Update(ProviderBindingModel model)
 {
     using (var context = new TechiqueShopDatabase())
     {
         var element = context.Providers.FirstOrDefault(rec => rec.Id ==
                                                        model.Id);
         if (element == null)
         {
             throw new Exception("Провайдер не найден");
         }
         CreateModel(model, element);
         context.SaveChanges();
     }
 }
Example #3
0
 public void Delete(ProviderBindingModel model)
 {
     using (var context = new TechiqueShopDatabase())
     {
         Provider element = context.Providers.FirstOrDefault(rec => rec.Id ==
                                                             model.Id);
         if (element != null)
         {
             context.Providers.Remove(element);
             context.SaveChanges();
         }
         else
         {
             throw new Exception("Провайдер не найден");
         }
     }
 }