public IActionResult Edit(int id, PromocaoVM promocaoVM) { if (id != promocaoVM.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _service.Update(promocaoVM.ToModel()); } catch (Exception ex) { if (!PromocaoExists(promocaoVM.Id)) { return(NotFound()); } else { ViewBag.Erro = ex.Message; throw; } } return(RedirectToAction(nameof(Index))); } return(View(promocaoVM)); }
public IActionResult Create(PromocaoVM promocaoVM) { if (ModelState.IsValid) { _service.Add(promocaoVM.ToModel()); return(RedirectToAction("Index")); } return(View(promocaoVM)); }