예제 #1
0
        public async Task InsertHorasAsync(int projetoId, LancamentoPost lancamentoPost)
        {
            if (lancamentoPost == null)
            {
                throw new ArgumentNullException(nameof(lancamentoPost));
            }


            if (lancamentoPost.DataFim < lancamentoPost.DataInicio)
            {
                throw new ArgumentException("Datas inválidas");
            }

            if (projetoId <= 0)
            {
                throw new ArgumentException("Projeto inválido");
            }


            var lancamento = new Lancamento()
            {
                ProjetoId       = projetoId,
                DesenvolvedorId = lancamentoPost.DesenvolvedorId,
                DataFim         = lancamentoPost.DataFim,
                DataInicio      = lancamentoPost.DataInicio
            };

            await _context.Lancamentos.AddAsync(lancamento);

            await _context.SaveChangesAsync();
        }
예제 #2
0
        public async Task <IActionResult> InsertLancamentoAsync(int id, LancamentoPost lancamentoPost)
        {
            await _projetoService.InsertHorasAsync(id, lancamentoPost);

            return(NoContent());
        }