/// <summary>
        /// Sets all the scheduled battles open for public when they reach the end date. It also changes the participant status of the participants who
        /// have not responded to the challenge
        /// </summary>
        public void SetScheduledBattlesOpenOrClosed()
        {
            //get the battles which have acceptance date equal to or less than now
            var now          = DateTime.UtcNow;
            var videoBattles =
                _videoBattleRepository.Table.Where(
                    x =>
                    (x.VotingStartDate <= now || x.VotingEndDate <= now) &&
                    (x.VideoBattleStatus == VideoBattleStatus.Pending ||
                     x.VideoBattleStatus == VideoBattleStatus.Locked)).ToList();

            foreach (var battle in videoBattles)
            {
                //do we need to open or complete the battle?
                if (battle.VotingEndDate <= now)
                {
                    //lets complete the battle as it's more than voting last date
                    battle.VideoBattleStatus = VideoBattleStatus.Complete;
                }
                else if (battle.VotingStartDate <= now)
                {
                    //get participants of this battle
                    var participants = _videoBattleParticipantRepository.Table.Where(x => x.VideoBattleId == battle.Id);

                    //all the participants who have not accepted will now be changed to denied
                    foreach (var participant in participants.Where(x => x.ParticipantStatus == VideoBattleParticipantStatus.Challenged || x.ParticipantStatus == VideoBattleParticipantStatus.SignedUp).ToList())
                    {
                        participant.ParticipantStatus = participant.ParticipantStatus == VideoBattleParticipantStatus.SignedUp ? VideoBattleParticipantStatus.ChallengeCancelled : VideoBattleParticipantStatus.ChallengeDenied;
                        _videoBattleParticipantRepository.Update(participant);
                    }

                    //let's see if there are enough participants to open the battle (at least two)
                    if (participants.Count(x => x.ParticipantStatus == VideoBattleParticipantStatus.ChallengeAccepted) > 0)
                    {
                        //and do we have at least two videos for competition
                        var battleVideoCount = _videoBattleVideoRepository.Table.Count(x => x.VideoBattleId == battle.Id);
                        //depending on the number of videos, battle can be either open or closed or complete
                        if (battleVideoCount == 0)
                        {
                            battle.VideoBattleStatus = VideoBattleStatus.Closed;
                        }
                        else if (battleVideoCount > 1)
                        {
                            battle.VideoBattleStatus = VideoBattleStatus.Open;
                        }
                        else
                        {
                            //only one video has been uploaded and by default, he should be the winner? (I guess). BTW the battle is complete then.
                            battle.VideoBattleStatus = VideoBattleStatus.Complete;
                        }
                    }
                    else
                    {
                        //so nobody accepted the challenge...too bad...let's close the battle then
                        battle.VideoBattleStatus = VideoBattleStatus.Closed;
                    }
                }

                _videoBattleRepository.Update(battle);

                //do we need to post to timeline?
                if (battle.AutomaticallyPostEventsToTimeline)
                {
                    switch (battle.VideoBattleStatus)
                    {
                    case VideoBattleStatus.Open:
                        _timelineAutoPublisher.Publish(battle, TimelineAutoPostTypeNames.VideoBattle.BattleStart);
                        break;

                    case VideoBattleStatus.Complete:
                        _timelineAutoPublisher.Publish(battle, TimelineAutoPostTypeNames.VideoBattle.BattleComplete);
                        break;
                    }
                }
                //depending on battle status, let's send notifications
                if (battle.VideoBattleStatus == VideoBattleStatus.Open || battle.VideoBattleStatus == VideoBattleStatus.Complete)
                {
                    //get the followers first
                    var followers           = _customerFollowService.GetFollowers <VideoBattle>(battle.Id);
                    var followerCustomerIds = followers.Select(x => x.CustomerId).ToArray();

                    //and their customers
                    var customers = _customerService.GetCustomersByIds(followerCustomerIds);
                    switch (battle.VideoBattleStatus)
                    {
                    case VideoBattleStatus.Open:
                        //send battle open notifications
                        foreach (var customer in customers)
                        {
                            _mobSocialMessageService.SendVideoBattleOpenNotification(customer, battle,
                                                                                     _workContext.WorkingLanguage.Id, _storeContext.CurrentStore.Id);
                        }
                        break;

                    case VideoBattleStatus.Complete:
                        //send battle complete notifications
                        foreach (var customer in customers)
                        {
                            _mobSocialMessageService.SendVideoBattleCompleteNotification(customer, battle,
                                                                                         NotificationRecipientType.Voter, _workContext.WorkingLanguage.Id,
                                                                                         _storeContext.CurrentStore.Id);
                        }
                        break;
                    }
                }
            }
        }