Beispiel #1
0
        public async Task <IActionResult> OnGetAdicionar(int Desenv_Id, int Proj_Id, string DataInicio, string DataFim, string Hora)
        {
            var DataInvalida = new DateTime();

            if (Desenv_Id == 0 || Proj_Id == 0 || String.IsNullOrEmpty(Hora) || DateTime.Parse(DataInicio) == DataInvalida || DateTime.Parse(DataFim) == DataInvalida)
            {
                return(new JsonResult(new { ok = false, msg = "Preencha todos os campos. " }));
            }

            if ((!Hora.Contains(":")) || (!DataInicio.Contains("/")) || (!DataFim.Contains("/")))
            {
                return(new JsonResult(new { ok = false, msg = "Digite os campos de forma correta" }));
            }

            if (DateTime.Parse(DataFim) >= DateTime.Now.AddDays(+1).Date)
            {
                return(new JsonResult(new { ok = false, msg = "Data Fim não pode ser maior que o dia atual." }));
            }

            var D = await new ChamadaProjeto(_configuration["URLs:LH.Service"]).DesenvolvedoresPorProjetoId(Proj_Id);
            var Desenv_Proj_Id = D.FirstOrDefault(x => x.Tb_DesenvolvedorId == Desenv_Id).Id;

            var r = await new ChamadaLancamentoHora(_configuration["URLs:LH.Service"]).Incluir(Desenv_Proj_Id, DataInicio, DataFim, Hora);

            if (r == "OK")
            {
                return(new JsonResult(new { ok = true }));
            }
            else
            {
                modal = new Tb_LancamentoHoras();
                return(new JsonResult(new { ok = false, msg = "Erro não identicado ocorrido. " + r }));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> OnGet(int?Id)
        {
            modal = new Tb_LancamentoHoras();
            var listaProj = await new ChamadaProjeto(_configuration["URLs:LH.Service"]).Listar();

            ListProjeto = listaProj.Where(x => x.InAtivo == true).ToList().Select(c => new SelectListItem()
            {
                Text = c.Nome, Value = c.Id.ToString()
            }).ToList();
            var Result = await new ChamadaLancamentoHora(_configuration["URLs:LH.Service"]).Listar();

            if (Id != null)
            {
                ModoTela = "V";
                modal    = Result.FirstOrDefault(x => x.Id == (int)Id);
            }
            else
            {
                ModoTela = "I";
            }

            if (Result.Count() != 0)
            {
                modal.Id = Result.LastOrDefault().Id + 1;
            }
            else
            {
                modal.Id = 1;
            }
            return(Page());
        }
Beispiel #3
0
        public async Task <IActionResult> OnGet()
        {
            var listaProj = await new ChamadaProjeto(_configuration["URLs:LH.Service"]).Listar();

            ListProjeto = listaProj.Select(c => new SelectListItem()
            {
                Text = c.Nome, Value = c.Id.ToString()
            }).ToList();
            modalResult = await new ChamadaLancamentoHora(_configuration["URLs:LH.Service"]).Listar();
            modalBusca  = new Tb_LancamentoHoras();
            return(Page());
        }
Beispiel #4
0
 public async Task <IActionResult> OnGetBuscar(int Id_Projeto, string NomeDesenv)
 {
     if (NomeDesenv == null && Id_Projeto == 0)
     {
         modalResult = await new ChamadaLancamentoHora(_configuration["URLs:LH.Service"]).Listar();
     }
     else
     {
         modalBusca  = new Tb_LancamentoHoras();
         modalResult = await new ChamadaLancamentoHora(_configuration["URLs:LH.Service"]).Buscar(NomeDesenv, Id_Projeto.ToString());
     }
     return(new JsonResult(new { ok = true, result = modalResult }));
 }
        public async Task <IActionResult> Incluir(string Desenv_Proj_Id, string DataInicio, string DataFim, string Hora)
        {
            try
            {
                var lh = new Tb_LancamentoHoras();
                lh.Tb_Desenvolvedor_ProjetoId = int.Parse(Desenv_Proj_Id);
                lh.DataInicio = DateTime.Parse(DataInicio);
                lh.DataFim    = DateTime.Parse(DataFim);
                lh.Horas      = Hora;

                await _context.Tb_LancamentosHoras.AddAsync(lh);

                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 }));
            }
        }