Example #1
0
        private async Task <DonorDto> GetDonor()
        {
            var donors = await donorService.GetDonorsAsync();

            if (!donors.Any())
            {
                throw new InvalidOperationException("No donors exist");
            }
            return(mapper.Map <DonorDto>(donors.FirstOrDefault()));
        }
        public MockDonationRepository(FundContext dbContext,
                                      IFundraiserRepository fundraiserRepository,
                                      IDonorRepository donorRepository)
        {
            this.dbContext            = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
            this.fundraiserRepository = fundraiserRepository ?? throw new ArgumentNullException(nameof(fundraiserRepository));
            this.donorRepository      = donorRepository ?? throw new ArgumentNullException(nameof(donorRepository));

            Donations = new List <Donation> {
                new Donation {
                    FundraiserId = fundraiserRepository.GetFundraisersAsync().Result.First().Id,
                    DonorId      = donorRepository.GetDonorsAsync().Result.First().Id,
                    Amount       = 10,
                    DonationDate = DateTimeOffset.Now
                },

                new Donation {
                    FundraiserId = fundraiserRepository.GetFundraisersAsync().Result.First().Id,
                    DonorId      = donorRepository.GetDonorsAsync().Result.Last().Id,
                    Amount       = 40,
                    DonationDate = DateTimeOffset.Now
                },
            };
        }
Example #3
0
 // GET: Donors
 public async Task <IActionResult> Index()
 {
     return(View(await _repository.GetDonorsAsync()));
 }