public async Task <List <PaymentNotification> > GetByHiDee(string transactionType, string hiDee)
        {
            var user = await _context.Users.Where(x => x.HiDee == hiDee).FirstOrDefaultAsync();

            if (user == null)
            {
                throw new AppException("User is not found");
            }

            if (user.HiDee.Equals(GlobalVariables.BaseKey()))
            {
                if (transactionType == "All")
                {
                    return(await _context.PaymentNotifications.OrderByDescending(x => x.DateAdded).ToListAsync());
                }
                else
                {
                    return(await _context.PaymentNotifications.Where(x => x.TransactionType == transactionType)
                           .OrderByDescending(x => x.DateAdded).ToListAsync());
                }
            }
            else
            {
                if (transactionType == "All")
                {
                    return(await _context.PaymentNotifications.Where(x => x.Email == user.Email)
                           .OrderByDescending(x => x.DateAdded).ToListAsync());
                }
                else
                {
                    return(await _context.PaymentNotifications.Where(x => (x.Email == user.Email) && (x.TransactionType == transactionType))
                           .OrderByDescending(x => x.DateAdded).ToListAsync());
                }
            }
        }
Esempio n. 2
0
        public async Task Delete(int id)
        {
            var user = await _context.Users.FindAsync(id);

            if (user != null || ((user != null) && (!user.HiDee.Equals(GlobalVariables.BaseKey()))))
            {
                _context.Users.Remove(user);
                await _context.SaveChangesAsync();
            }
        }
        public async Task <List <PaymentNotification> > Confirm(string reference, string hiDee)
        {
            var paymentNotification = await _context.PaymentNotifications.Where(x => x.Reference == reference).FirstOrDefaultAsync();

            if (paymentNotification == null)
            {
                throw new AppException("Payment notification is not found");
            }

            var user = await _context.Users.Where(x => x.Email == paymentNotification.Email).FirstOrDefaultAsync();

            if (user == null || ((user != null) && (!hiDee.Equals(GlobalVariables.BaseKey()))))
            {
                throw new AppException("User is not found");
            }

            if (paymentNotification.Confirmed == "Yes")
            {
                paymentNotification.Confirmed     = "No";
                paymentNotification.UpdateAllowed = true;
                await _transactionService.Delete(paymentNotification.Reference);

                if (paymentNotification.TransactionType == "Activation")
                {
                    user.ActivationRequested = true;
                    user.ActivationFeePaid   = false;
                }
            }
            else
            {
                paymentNotification.Confirmed     = "Yes";
                paymentNotification.UpdateAllowed = false;
                var transaction = new Transaction {
                    Reference       = paymentNotification.Reference,
                    TransactionType = paymentNotification.TransactionType,
                    Email           = paymentNotification.Email,
                    AmountPaid      = paymentNotification.AmountPaid,
                    PaymentChannel  = paymentNotification.PaymentChannel
                };
                await _transactionService.Add(transaction);

                if (paymentNotification.TransactionType == "Activation")
                {
                    user.ActivationRequested = true;
                    user.ActivationFeePaid   = true;
                }
            }

            _context.PaymentNotifications.Update(paymentNotification);
            _context.Users.Update(user);
            await _context.SaveChangesAsync();

            return(await _context.PaymentNotifications.OrderByDescending(x => x.DateAdded).ToListAsync());
        }
Esempio n. 4
0
        public async Task <IList <Guarantor> > GetGuaranteeByHiDee(GuarantorDto guarantorDto)
        {
            var user = await _context.Users.Where(x => x.HiDee == guarantorDto.UserHiDee).FirstOrDefaultAsync();

            if (user.HiDee.Equals(GlobalVariables.BaseKey()))
            {
                return(null);
            }
            else
            {
                return(await _context.Guarantors.Where(x => x.GuaranteeEmail == user.Email)
                       .OrderByDescending(x => x.DateAdded).ToListAsync());
            }
        }
Esempio n. 5
0
        public async Task <IList <User> > CanGuarantee(string hiDee, string userHiDee)
        {
            var user = await _context.Users.Where(x => x.HiDee == hiDee).FirstOrDefaultAsync();

            if (user == null || (!userHiDee.Equals(GlobalVariables.BaseKey())))
            {
                throw new AppException("User is not found");
            }
            user.CanGuarantee = !user.CanGuarantee;
            _context.Users.Update(user);
            await _context.SaveChangesAsync();

            return(await _context.Users.OrderByDescending(x => x.DateAdded).ToListAsync());
        }
Esempio n. 6
0
        public async Task <IList <User> > GetByHiDee(string hiDee)
        {
            var user = await _context.Users.Where(x => x.HiDee == hiDee).FirstOrDefaultAsync();

            if (user.HiDee.Equals(GlobalVariables.BaseKey()))
            {
                return(await _context.Users.OrderByDescending(x => x.DateAdded).ToListAsync());
            }
            else
            {
                return(await _context.Users.Where(x => x.HiDee == hiDee)
                       .OrderByDescending(x => x.DateAdded).ToListAsync());
            }
        }
        public async Task <IActionResult> GetByHiDee([FromForm] PaymentNotificationDto paymentNotificationDto)
        {
            var paymentNotificationByHiDee = await _paymentNotificationService.GetByHiDee(paymentNotificationDto.TransactionType, paymentNotificationDto.UserHiDee);

            if (paymentNotificationDto.UserHiDee.Equals(GlobalVariables.BaseKey()))
            {
                var paymentNotificationDtoAdmin = _mapper.Map <IList <PaymentNotificationDto> >(paymentNotificationByHiDee);
                return(Ok(paymentNotificationDtoAdmin));
            }
            else
            {
                var paymentNotificationDtoUser = _mapper.Map <IList <PaymentNotificationDtoUser> >(paymentNotificationByHiDee);
                return(Ok(paymentNotificationDtoUser));
            }
        }
        public async Task <IActionResult> GetByHiDee([FromForm] TransactionDto transactionDto)
        {
            var transactionByHiDee = await _transactionService.GetByHiDee(transactionDto.TransactionType, transactionDto.UserHiDee);

            if (transactionDto.UserHiDee.Equals(GlobalVariables.BaseKey()))
            {
                var transactionDtoAdmin = _mapper.Map <IList <TransactionDto> >(transactionByHiDee);
                return(Ok(transactionDtoAdmin));
            }
            else
            {
                var transactionDtoUser = _mapper.Map <IList <TransactionDtoUser> >(transactionByHiDee);
                return(Ok(transactionDtoUser));
            }
        }
        public async Task <IActionResult> CanGuarantee([FromForm] UserDtoAdmin userDtoAdmin)
        {
            var user = await _userService.CanGuarantee(userDtoAdmin.HiDee, userDtoAdmin.UserHiDee);

            if (userDtoAdmin.HiDee.Equals(GlobalVariables.BaseKey()))
            {
                var userDtoAdminn = _mapper.Map <IList <UserDtoAdmin> >(user);
                return(Ok(userDtoAdminn));
            }
            else
            {
                var userDtoUser = _mapper.Map <IList <UserDtoUser> >(user);
                return(Ok(userDtoUser));
            }
        }