public IActionResult Delete(EmpresaEliminarViewModel model) { if (ModelState.IsValid) { var company = _context.Empresas.FirstOrDefault(e => e.EmpId == model.EmpId); _context.Empresas.Remove(company); _context.SaveChanges(); this.ShowSuccess("La empresa se ha eliminado correctamente"); return(this.RedirectAjax(Url.Action("Index"))); } return(PartialView("_DeletePartial", model)); }
public IActionResult Delete(string id) { var company = _context.Empresas.FirstOrDefault(e => e.EmpId == id); if (company == null) { this.ShowSuccess("La empresa que intenta eliminar ya no existe"); return(this.RedirectAjax(Url.Action("Index"))); } var model = new EmpresaEliminarViewModel() { EmpId = company.EmpId }; return(PartialView("_DeletePartial", model)); }