Пример #1
0
        public IActionResult Put(Guid idAluguel, bool renovar)
        {
            try
            {
                var aluguel = _repositoryAluguel.ObterAluguelPorId(idAluguel);
                if (!renovar)
                {
                    var filmes = aluguel.AluguelFilmes.Select(m => m.Filme).ToList();
                    aluguel.RealizarDevolucao(filmes);
                    foreach (var filme in filmes)
                    {
                        _repositoryFilme.EditarFilme(filme);
                    }
                }

                else
                {
                    aluguel.RenovarEmprestimo();
                }

                _repositoryAluguel.AlterarAluguel(aluguel);

                return(Ok(aluguel));
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }