Esempio n. 1
0
        public IActionResult alunoPegaMerenda(string AlunoMatricula, int COD_Estoque, int LancheId)
        {
            var aluno   = _alunoRepository.GetByMatricula(AlunoMatricula);
            var estoque = _estoqueRepository.GetByCOD(COD_Estoque);

            if (aluno != null)
            {
                estoque.QtdEstoque--;
                if (estoque.QtdEstoque >= 0)
                {
                    _estoqueRepository.Update(estoque, estoque.Id);
                    var alunoLanche = new AlunoLanche()
                    {
                        AlunoId  = aluno.Id,
                        LancheId = LancheId
                    };
                    _alunoLancheRepository.Create(alunoLanche);
                    return(Ok("Lanche Registrado"));
                }
                else
                {
                    return(BadRequest("Estoque esgotado!"));
                }
            }
            return(BadRequest("Aluno não existe"));
        }
        public IActionResult GetCod(int id)
        {
            var entity = _repository.GetByCOD(id);

            if (entity == null)
            {
                return(NotFound());
            }
            return(Ok(entity));
        }
Esempio n. 3
0
        public IActionResult GetValorGasto(AlunoLancheFilter filter)
        {
            //Console.WriteLine(filter.Dia);
            var valorFinal = 0.0;
            var alunoLache = _repository.GetForRelatorio(filter);

            foreach (var al in alunoLache)
            {
                var estoque = _estoqueRepository.GetByCOD(al.Lanche.COD_Estoque);
                valorFinal += estoque.Valor;
            }

            return(Ok(valorFinal));
        }