public ActionResult Edit(ProductAndService productAndService) { if (ModelState.IsValid) { this.services.Update(productAndService); return(RedirectToAction("Index")); } return(View(productAndService)); }
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}."); } }
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}."); } }