public async Task <IActionResult> Add(string id) { ViewBag.IsEditing = "N"; var title = "Adicionar"; SOL_DeptoAddEditVM model = null; if (!String.IsNullOrEmpty(id)) { var data = await _deptoRepo.GetAsync(id); if (data == null) { return(NotFound()); } model = data.ToVM(); title = "Editar"; ViewBag.IsEditing = "S"; } ViewBag.Title = $"{title} Departamento"; return(View(model)); }
public async Task <IActionResult> Add(string id, SOL_DeptoAddEditVM model) { if (!ModelState.IsValid) { return(View(model)); } var data = model.ToData(); if (String.IsNullOrEmpty(id)) { _deptoRepo.Add(data); } else { _deptoRepo.Update(data); } await _uow.CommitAsync(); return(RedirectToAction("Index")); }