public async Task <IActionResult> OnGet() { modalResult = await new ChamadaProjeto(_configuration["URLs:LH.Service"]).Listar(); modalResult = modalResult.Where(x => x.InAtivo == true).ToList(); modalBusca = new Tb_Projeto(); return(Page()); }
public async Task <IActionResult> OnGet(int?id) { modal = new Tb_Projeto(); if (id == null) { var Result = await new ChamadaProjeto(_configuration["URLs:LH.Service"]).Listar(); if (Result.Count() != 0) { modal.Id = Result.LastOrDefault().Id + 1; } else { modal.Id = 1; } modal.TipoTela = "I"; } else { var r = await new ChamadaProjeto(_configuration["URLs:LH.Service"]).Buscar((int)id, ""); var Result = r.FirstOrDefault(); modal.Id = Result.Id; modal.Nome = Result.Nome; modal.TipoTela = "E"; HttpContext.Session.SetInt32("P_Edit", (int)id); var listaDesenvolvedor = await new ChamadaProjeto(_configuration["URLs:LH.Service"]).DesenvolvedoresPorProjetoId((int)id); foreach (var item in listaDesenvolvedor) { modal.ListaDesenvolvedor = modal.ListaDesenvolvedor + "/" + item.Tb_Desenvolvedor.Nome; } } return(Page()); }
public async Task <IActionResult> OnGetBuscar(int id, string nome) { if (nome == null && id == 0) { modalResult = await new ChamadaProjeto(_configuration["URLs:LH.Service"]).Listar(); modalResult = modalResult.Where(x => x.InAtivo == true).ToList(); } else { modalBusca = new Tb_Projeto(); modalBusca.Id = id; modalBusca.Nome = nome; modalResult = await new ChamadaProjeto(_configuration["URLs:LH.Service"]).Buscar(id, nome); } return(new JsonResult(new { ok = true, result = modalResult })); }
public async Task <IActionResult> Incluir(string Nome, string Desenvolvedores) { try { var P = new Tb_Projeto(); P.InAtivo = true; P.Nome = Nome; await _context.Tb_Projetos.AddAsync(P); await _context.SaveChangesAsync(); int Proj_id = P.Id; if (Desenvolvedores != null) { var DevsArray = Desenvolvedores.Split("/"); foreach (var item in DevsArray) { if (!String.IsNullOrEmpty(item)) { var tbDev_proj = new Tb_Desenvolvedor_Projeto(); tbDev_proj.Tb_ProjetoId = Proj_id; tbDev_proj.InAtivo = true; tbDev_proj.Tb_Desenvolvedor = _context.Tb_Desenvolvedores.FirstOrDefault(x => x.Nome == item); if (tbDev_proj.Tb_Desenvolvedor != null) { tbDev_proj.Tb_DesenvolvedorId = tbDev_proj.Tb_Desenvolvedor.Id; await _context.Tb_Desenvolvedores_Projetos.AddAsync(tbDev_proj); } } } } await _context.SaveChangesAsync(); return(StatusCode(200)); } catch (Exception ex) { var errorId = Guid.NewGuid(); _logger.LogError(ex, "ErrorId: {0}", errorId.ToString()); return(StatusCode(500, new { ErrorId = errorId.ToString(), Mensagem = ex.Message })); } }
public async Task <IActionResult> OnGetAdicionar(string nome, string TipoTela, string Desenvolvedores) { int?id = HttpContext.Session.GetInt32("P_Edit"); if (String.IsNullOrEmpty(nome)) { return(new JsonResult(new { ok = false, msg = "Digite um nome." })); } var Result = await new ChamadaProjeto(_configuration["URLs:LH.Service"]).Listar(); if (Result.Any(x => x.Nome.ToLower() == nome.ToLower() && (TipoTela == "E" ? x.Id != (int)id : true))) { return(new JsonResult(new { ok = false, msg = "Esse nome já está cadastrado!" })); } var r = string.Empty; if (TipoTela == "E") { r = await new ChamadaProjeto(_configuration["URLs:LH.Service"]).Alterar((int)id, nome, Desenvolvedores); } else { r = await new ChamadaProjeto(_configuration["URLs:LH.Service"]).Incluir(nome, Desenvolvedores); } if (r == "OK") { return(new JsonResult(new { ok = true })); } else { modal = new Tb_Projeto(); modal.Nome = nome; return(new JsonResult(new { ok = false, msg = "Erro não identicado ocorrido." })); } }