public IHttpActionResult GetDonations(string donationYear = null, int?limit = null, [FromUri(Name = "softCredit")] bool?softCredit = null, [FromUri(Name = "impersonateDonorId")] int?impersonateDonorId = null, bool?includeRecurring = true) { return(Authorized(token => { var impersonateUserId = impersonateDonorId == null ? string.Empty : _mpDonorService.GetEmailViaDonorId(impersonateDonorId.Value).Email; try { var donations = (impersonateDonorId != null) ? _impersonationService.WithImpersonation(token, impersonateUserId, () => _gatewayDonationService.GetDonationsForAuthenticatedUser(token, donationYear, limit, softCredit, includeRecurring)) : _gatewayDonationService.GetDonationsForAuthenticatedUser(token, donationYear, limit, softCredit, includeRecurring); if (donations == null || !donations.HasDonations) { return (RestHttpActionResult <ApiErrorDto> .WithStatus(HttpStatusCode.NotFound, new ApiErrorDto("No matching donations found"))); } return (Ok(donations)); } catch (UserImpersonationException e) { return (e.GetRestHttpActionResult()); } })); }