public ActionResult Cadastrar(List <Domain.Entities.Empresa> empresas) { using (var client = new Infra.Data.Repositories.EmpresaRepository()) { var feed = new Services.FeedBack { Message = "Erro ao cadastrar", Status = "ERRO" }; try { empresas.ForEach((item) => { if (client.GetByCNPJ(item.Cnpj) == null) { client.Add(item); } }); feed.Status = "OK"; return(Json(feed)); } catch (Exception ex) { return(Json(feed)); } } }
public ActionResult Listar() { using (var client = new Infra.Data.Repositories.EmpresaRepository()) { try { var empresas = client.GetAll().ToList(); return(Json(empresas, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("{}", JsonRequestBehavior.AllowGet)); } } }