public ActionResult ConfirmarDeletar(int id) { var categoria = _categoriaApp.GetById(id); var servicoCategoria = _servicoApp.RetornaServicoPelaCategoria(id); if (servicoCategoria.Count > 0) { msgRetorno = "Esta categoria não pode ser excluída, pois existem serviços vinculados a ela."; } else { _categoriaApp.Remove(categoria); msgRetorno = "Categoria excluída com sucesso"; } return(RedirectToAction("Index")); }
//retorna os serviços pela categoria public JsonResult RServicosPCategoria(string id) { List <ServicoIdNome> retorno = _iServicoApp.RetornaServicoPelaCategoria(Convert.ToInt32(id)); return(Json(retorno, JsonRequestBehavior.AllowGet)); }