public IActionResult GetRecipientDonations(DonationStatus status) { var user = userRepository.GetUserFromPrincipal(HttpContext.User); if (!userRepository.IsActiveUser(user)) { return(new UnauthorizedResult()); } // Recipients can only have pending and completed donations if (status == DonationStatus.Wasted || status == DonationStatus.Listed) { return(BadRequest()); } var donations = donationRepository.GetByRecipientIdWithStatus(user.Id, (int)status); foreach (var donation in donations) { donation.Donor = userRepository.GetById(donation.DonorId); } return(Ok(donations)); }