Exemplo n.º 1
0
        public IActionResult GetDonations()
        {
            var donationsEntity = _donationRepository.GetAll();
            var donationDtos    = _mapper.Map <List <DonationDto> >(donationsEntity);

            return(Ok(donationDtos));
        }
Exemplo n.º 2
0
        public IActionResult GetAll()
        {
            var donationsDb       = _donation.GetAll();
            var donationsResponse = _mapper.Map <ICollection <DonationResponse> >(donationsDb);

            return(Ok(donationsResponse));
        }
Exemplo n.º 3
0
        // GET: Dashboard
        public async Task <ActionResult> Index()
        {
            var currentUser = await GetCurrentUser();

            var pendingRewardDonation = _rewardDonationRepository.GetAll()
                                        .Include(d => d.ToUser)
                                        .FirstOrDefault(d => d.FromUserId == AbpSession.UserId.Value &&
                                                        d.Status == Status.Pending);

            var viewModel = new DashboardViewModel
            {
                PendingRewardDonation = pendingRewardDonation,
                CurrentUser           = currentUser,
                Transactions          = _donationRepository.GetTransactions(AbpSession.UserId.Value),
                PendingDonation       =
                    _donationRepository.GetAll()
                    .Include(d => d.ToUser)
                    .FirstOrDefault(d => d.FromUserId == AbpSession.UserId.Value &&
                                    d.Status == Status.Pending),
                PendingPackage = _packageRepository.FirstOrDefault(p => p.UserId == AbpSession.UserId.Value &&
                                                                   p.Status != Status.PaidOut),
                PendingConfirmations         = _donationRepository.GetPendingConfirmations(AbpSession.UserId.Value),
                Downlines                    = _referralRepository.GetAll().Where(r => r.UserId == AbpSession.UserId.Value).Select(r => r.Downline).ToList(),
                ReferralPendingConfirmations = _rewardDonationRepository.GetPendingConfirmations(AbpSession.UserId.Value)
            };

            if (viewModel.PendingPackage != null && viewModel.PendingPackage.Status == Status.Pending)
            {
                FlashSuccess("You have a pendnig package. Please hold on for the system to pair you");
            }

            return(View(viewModel));
        }
Exemplo n.º 4
0
        private OutputResultDto ConfirmRewardDonation(ConfirmDonationInput input)
        {
            var donation = _rewardDonationRepository.FirstOrDefault(d => d.Id == input.DonationId &&
                                                                    d.ToUserId == input.CurrentUserId);

            if (donation == null)
            {
                return(new OutputResultDto {
                    Message = "Invalid Donation ID"
                });
            }
            donation.Status = Status.PaidOut;
            _rewardDonationRepository.Update(donation);

            var ticket = _referralRewardTicketRepository.FirstOrDefault(t => t.Id == donation.TicketId);

            //mark the ticket as paid out
            ticket.Status = Status.PaidOut;
            _referralRewardTicketRepository.InsertOrUpdateAndGetId(ticket);

            //if the actual donation for this package have been confirmed create tickets for the package
            if (_donationRepository.GetAll().Any(d => d.PackageId == donation.PackageId && d.Status == Status.PaidOut))
            {
                var result = CreateDonationTicket(new CreateDonationTicketInput {
                    PackageId = donation.PackageId
                });
                if (!result.Success)
                {
                    //todo log ticket creation error
                }
            }
            return(new OutputResultDto {
                Message = "Thanks for confirming the donation", Success = true
            });
        }
 public IEnumerable <Donation> GetAll(string keyword)
 {
     if (string.IsNullOrEmpty(keyword))
     {
         return(_donationRepository.GetAll());
     }
     else
     {
         return(_donationRepository.GetMulti(x => x.Name.Contains(keyword)));
     }
 }
Exemplo n.º 6
0
        public IEnumerable <Donation> GetDonations()
        {
            var donations = _donationRepository.GetAll().ToList();

            return(donations.OrderByDescending(x => x.Id));
        }
Exemplo n.º 7
0
        public IEnumerable <Donation> GetTopDonations(int count)
        {
            var donations = _repository.GetAll().OrderByDescending(d => d.Amount).Take(count);

            return(donations);
        }
Exemplo n.º 8
0
 public IReadOnlyCollection <Donation> GetAll()
 {
     return(_donationRepository.GetAll());
 }