Exemplo n.º 1
0
        public IActionResult Waste(int id)
        {
            var user = userRepository.GetUserFromPrincipal(HttpContext.User);

            if (!userRepository.IsActiveUser(user))
            {
                return(new UnauthorizedResult());
            }

            var donation = donationRepository.GetById(id);

            if (donation == null)
            {
                return(new NotFoundResult());
            }

            if (donation.DonorId != user.Id)
            {
                return(new UnauthorizedResult());
            }

            donationRepository.WasteDonation(id);
            return(Ok());
        }