public bool MakeRandomMoCPayment(Utilities.TimeSpan timeSpan)
        {
            var systemValues   = _systemValueService.GetNewestSystemValue();
            var totalUserCount = _userService.GetAllUsersCount(timeSpan);

            //If the amount of users (as of now) is greater than the min threshold
            if (totalUserCount > systemValues.AirdropTotalUserCountMinThreshold)
            {
                Random rnd = new Random();
                //Get a random percent payout 10~20
                int giveAway = rnd.Next(systemValues.AirdropMinThresholdUserPercent, systemValues.AirdropMaxThresholdUserPercent);
                //Get the number of users based on the random percentage > and round up
                double usersToGiveAway = Math.Ceiling(
                    ((double)(totalUserCount) / 100.0) * ((double)giveAway)
                    );
                var randomUsers = _userService.GetRandomUsers(((int)usersToGiveAway), timeSpan.StartDate);

                foreach (var user in randomUsers)
                {
                    var amount = NumberUtility.GetRandomDouble(10, 100);
                    //Make transfer from admin account
                    var success = _creditWalletService.Transfer(systemValues.AdminUserId, user.Id, amount, TransferType.Airdrop);
                    if (success)
                    {
                        //Send message to user informing of success
                        _userMessageService.AddUserMessage($@"You have been randomly selected to recieve: {amount} MoC!",
                                                           user.Id, MessageStatus.Win.ToString());
                    }
                }
                return(true);
            }
            return(false);
        }
        public bool RunValidationForUser(long userId, long contentId, bool shouldBePersisted)
        {
            var contentToPersist     = _contentService.GetContentById(contentId);
            var userValidationExists = _userContentValidationService.HasUserValidatedAlready(userId, contentId);
            var systemValues         = _systemValuesService.GetNewestSystemValue();

            if (systemValues != null && contentToPersist != null && !userValidationExists)
            {
                var persistCount = _userContentValidationService.GetValidationsForContent(contentId, true)
                                   .Count();
                if (contentToPersist.AppliedForPersistence == true && contentToPersist.EligableForPersistanceAt != null &&
                    persistCount < systemValues.ValidationUserMaxCount && !contentToPersist.ReferredViaValidationToAdmin)
                {
                    var validated = _userContentValidationService.AddValidationRecord(userId, contentId, shouldBePersisted);
                    if (validated)
                    {
                        _activityService.AddActivity(ActivityTypeMap.ValidatedContent, contentId, userId, contentToPersist.SubDirectoryId);
                        if (persistCount >= systemValues.ValidationUserMaxCount)
                        {
                            EndValidationEvent(userId, contentId, systemValues.ValidationUserThresholdPercent,
                                               systemValues.ValidationUserMaxRunCount, systemValues.AmountToPayForUserValidation);
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
 public bool PayIntoWallets(IList <User> users, double amountToPay)
 {
     if (users != null && users.Any())
     {
         var systemValues = _systemValueService.GetNewestSystemValue();
         var adminId      = systemValues.AdminUserId;
         var amountToSend = systemValues.AmountToPayForTraining;
         foreach (var user in users)
         {
             Transfer(adminId, user.Id, amountToSend);
         }
         return(true);
     }
     return(false);
 }