public async Task <IActionResult> OnGet(int?id) { modal = new Tb_Desenvolvedor(); if (id == null) { var Result = await new ChamadaDesenvolvedor(_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 ChamadaDesenvolvedor(_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("D_Edit", (int)id); } return(Page()); }
public async Task <IActionResult> OnGetBuscar(int id, string nome) { if (nome == null && id == 0) { modalResult = await new ChamadaDesenvolvedor(_configuration["URLs:LH.Service"]).Listar(); } else { modalBusca = new Tb_Desenvolvedor(); modalBusca.Id = id; modalBusca.Nome = nome; modalResult = await new ChamadaDesenvolvedor(_configuration["URLs:LH.Service"]).Buscar(id, nome); } return(new JsonResult(new { ok = true, result = modalResult })); }
public async Task <IActionResult> Incluir(string Nome) { try { var D = new Tb_Desenvolvedor(); D.Nome = Nome; await _context.Tb_Desenvolvedores.AddAsync(D); 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) { if (String.IsNullOrEmpty(nome)) { return(new JsonResult(new { ok = false, msg = "Digite um nome." })); } int?id = HttpContext.Session.GetInt32("D_Edit"); var Result = await new ChamadaDesenvolvedor(_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 ChamadaDesenvolvedor(_configuration["URLs:LH.Service"]).Alterar((int)id, nome); } else { r = await new ChamadaDesenvolvedor(_configuration["URLs:LH.Service"]).Incluir(nome); } if (r == "OK") { return(new JsonResult(new { ok = true })); } else { modal = new Tb_Desenvolvedor(); modal.Nome = nome; return(new JsonResult(new { ok = false, msg = "Erro não identicado ocorrido." })); } }
public async Task <IActionResult> OnGet() { modalResult = await new ChamadaDesenvolvedor(_configuration["URLs:LH.Service"]).Listar(); modalBusca = new Tb_Desenvolvedor(); return(Page()); }