Пример #1
0
 public ActionResult Edit(ProductAndService productAndService)
 {
     if (ModelState.IsValid)
     {
         this.services.Update(productAndService);
         return(RedirectToAction("Index"));
     }
     return(View(productAndService));
 }
Пример #2
0
 public void Update(ProductAndService productAndService)
 {
     try
     {
         using (var context = new DBContext())
         {
             context.Entry(productAndService).State = EntityState.Modified;
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new CustomerServicesException($"Erro ao tentar atualizar um item: {ex.Message}.");
     }
 }
Пример #3
0
 public void Add(ProductAndService productAndService)
 {
     try
     {
         using (var context = new DBContext())
         {
             context.ProductsAndServices.Add(productAndService);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new CustomerServicesException($"Erro ao tentar adicionar este item: {ex.Message}.");
     }
 }