Example #1
0
        public static List <VotingClass> getVotingClassList(Entities e, Expression <Func <NEWS, bool> > expr, int page, int userId = 0)
        {
            List <NewsClass>   newsList = getNewsClassList(e, expr, page);
            List <VotingClass> votings  = new List <VotingClass>();

            foreach (var item in newsList)
            {
                var         serializedParent = JsonConvert.SerializeObject(item);
                VotingClass votingClass      = JsonConvert.DeserializeObject <VotingClass>(serializedParent);

                NEWS _NEWS = e.NEWS.FirstOrDefault(n => n.NEWS_ID == item.id);

                votingClass.voteType   = _NEWS.VOTE_TYPE;
                votingClass.voteResult = _NEWS.VOTE_RESULT;
                votingClass.voteCount  = _NEWS.VOTE_COUNT == 1 ? true : false;
                votingClass.expireDate = _NEWS.EXPIRATION_DATE;
                votingClass.choices    = getChoices(e, item.id, userId);


                foreach (var choice in votingClass.choices)
                {
                    votingClass.totalVotes += choice.voteCount;
                }

                votings.Add(votingClass);
            }

            return(votings);
        }
        public static VotingClass AddPoll(VotingClass poll, Guid memberId)
        {
            try
            {
                var member = MemberCache.GetMemberDisplay(memberId);
                var dc = new ManagementContext();
                RDN.Library.DataModels.Controls.Voting.VotingV2 voting = new DataModels.Controls.Voting.VotingV2();
                voting.IsDeleted = false;
                voting.IsPublic = poll.IsPublic;
                voting.IsPollAnonymous = poll.IsPollAnonymous;

                voting.LeagueOwner = dc.Leagues.Where(x => x.LeagueId == member.CurrentLeagueId).FirstOrDefault();
                voting.Description = poll.Description;
                voting.Title = poll.Title;
                voting.IsOpenToLeague = poll.IsOpenToLeague;

                for (int i = 0; i < poll.Questions.Count; i++)
                {
                    VotingQuestion question = new VotingQuestion();
                    question.Question = poll.Questions[i].Question;
                    question.QuestionSortId = i;
                    question.QuestionType = (int)poll.Questions[i].QuestionType;

                    for (int j = 0; j < poll.Questions[i].Answers.Count; j++)
                    {
                        if (!String.IsNullOrEmpty(poll.Questions[i].Answers[j].Answer))
                        {
                            VotingAnswer answer = new VotingAnswer();
                            answer.Answer = poll.Questions[i].Answers[j].Answer;
                            answer.Question = question;
                            question.Answers.Add(answer);
                        }
                    }

                    voting.Questions.Add(question);
                }
                //List<Guid> listOfGuids = new List<Guid>();

                foreach (var mem in poll.Voters)
                {
                    voting.Voters.Add(new VotingVoters() { HasVoted = false, Member = dc.Members.Where(x => x.MemberId == mem.MemberId).FirstOrDefault() });
                }

                dc.VotingV2.Add(voting);

                int c = dc.SaveChanges();
                poll.VotingId = voting.VotingId;
                if (poll.BroadcastPoll)
                {
                    var mems = MemberCache.GetLeagueMembers(memberId, member.CurrentLeagueId);
                    for (int j = 0; j < poll.Voters.Count; j++)
                    {
                        if (memberId != poll.Voters[j].MemberId)
                        {
                            var m = mems.Where(x => x.MemberId == poll.Voters[j].MemberId).FirstOrDefault();
                            SendEmailAboutNewPoll(poll.LeagueId, poll.VotingId, member.DerbyName, m.DerbyName, m.UserId);
                        }
                    }
                }
                List<Guid> memIds = poll.Voters.Select(x => x.MemberId).ToList();
                var fact = new MobileNotificationFactory()
                    .Initialize("New Poll Created:", poll.Title, Mobile.Enums.NotificationTypeEnum.NewPollCreated)
                    .AddId(poll.VotingId)
                    .AddMembers(memIds)
                    .SendNotifications();

            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: poll.ToMemberIds);
            }
            return poll;
        }
        public static VotingClass GetPollV2(Guid leagueId, long pollId, Guid mem)
        {
            VotingClass v = new VotingClass();
            var dc = new ManagementContext();
            try
            {
                var voting = dc.VotingV2.Where(x => x.LeagueOwner.LeagueId == leagueId && x.IsDeleted == false && x.VotingId == pollId).FirstOrDefault();
                if (voting == null)
                    return null;
                v.IsPublic = voting.IsPublic;
                v.IsClosed = voting.IsClosed;
                v.IsDeleted = voting.IsDeleted;
                v.IsOpenToLeague = voting.IsOpenToLeague;
                v.Title = voting.Title;
                v.Version = 2;
                foreach (var voter in voting.Voters)
                {
                    MemberDisplay m = new MemberDisplay();
                    m.MemberId = voter.Member.MemberId;
                    m.DerbyName = voter.Member.DerbyName;
                    m.PlayerNumber = voter.Member.PlayerNumber;
                    m.UserId = voter.Member.AspNetUserId;
                    v.Voters.Add(m);
                }
                //= MemberCache.GetLeagueMembers(mem, leagueId);
                foreach (var question in voting.Questions.OrderBy(x => x.QuestionSortId))
                {
                    VotingQuestionClass q = new VotingQuestionClass();
                    q.Question = question.Question;
                    q.SortableOrderId = question.QuestionSortId;
                    q.QuestionId = question.QuestionId;
                    q.QuestionType = (QuestionTypeEnum)question.QuestionType;
                    var answers = question.Answers.Where(x => x.WasRemoved == false).ToList();
                    for (int vo = 0; vo < answers.Count; vo++)
                    {
                        try
                        {
                            VotingAnswersClass vc = new VotingAnswersClass();
                            vc.Answer = answers[vo].Answer;
                            vc.AnswerId = answers[vo].AnswerId;
                            vc.WasRemoved = answers[vo].WasRemoved;
                            q.Answers.Add(vc);
                        }
                        catch (Exception exception)
                        {
                            ErrorDatabaseManager.AddException(exception, exception.GetType());
                        }
                    }
                    for (int vo = 0; vo < question.Votes.Count; vo++)
                    {
                        try
                        {
                            VotesClass vc = new VotesClass();
                            vc.IPAddress = question.Votes[vo].IPAddress;
                            vc.OtherText = question.Votes[vo].OtherText;
                            vc.Created = question.Votes[vo].Created;
                            if (question.Votes[vo].AnswerSelected != null)
                            {
                                vc.AnswerId = question.Votes[vo].AnswerSelected.AnswerId;
                                vc.AnswerIds.Add(vc.AnswerId);
                            }
                            foreach (var ans in question.Votes[vo].AnswersSelected)
                            {
                                vc.AnswerIds.Add(ans.AnswerSelected.AnswerId);
                            }
                            if (question.Votes[vo].Member != null)
                            {
                                vc.MemberId = question.Votes[vo].Member.MemberId;
                                vc.DerbyName = question.Votes[vo].Member.DerbyName;
                                vc.UserId = question.Votes[vo].Member.AspNetUserId;
                            }
                            vc.VoteId = question.Votes[vo].VoteId;
                            q.Votes.Add(vc);
                            v.Voters.Remove(v.Voters.Where(x => x.MemberId == vc.MemberId).FirstOrDefault());
                        }
                        catch (Exception exception)
                        {
                            ErrorDatabaseManager.AddException(exception, exception.GetType());
                        }
                    }
                    v.Questions.Add(q);
                }
                v.Description = voting.Description;
                v.IsClosed = voting.IsClosed;
                v.VotingId = voting.VotingId;
                v.IsPollAnonymous = voting.IsPollAnonymous;
                v.LeagueId = leagueId.ToString().Replace("-", "");
                //making due for old polls.

                return v;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return null;
        }
        public static bool DeletePoll(VotingClass poll)
        {
            var dc = new ManagementContext();
            try
            {
                Guid lId = new Guid(poll.LeagueId);

                var voting = dc.VotingV2.Where(x => x.LeagueOwner.LeagueId == lId && x.VotingId == poll.VotingId).FirstOrDefault();

                if (voting != null)
                {
                    voting.IsDeleted = true;
                }
                else
                {
                    var votingv1 = dc.Voting.Where(x => x.LeagueOwner.LeagueId == lId && x.VotingId == poll.VotingId).FirstOrDefault();
                    votingv1.IsDeleted = true;
                }
                int c = dc.SaveChanges();
                return c > 0;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }
        public static bool OpenPoll(VotingClass poll)
        {
            var dc = new ManagementContext();
            try
            {
                var mem = RDN.Library.Classes.Account.User.GetMemberId();
                Guid lId = new Guid(poll.LeagueId);

                var voting = dc.VotingV2.Where(x => x.LeagueOwner.LeagueId == lId && x.VotingId == poll.VotingId).FirstOrDefault();

                if (voting != null)
                {
                    voting.IsClosed = false;
                }
                else
                {
                    var votingv1 = dc.Voting.Where(x => x.LeagueOwner.LeagueId == lId && x.VotingId == poll.VotingId).FirstOrDefault();
                    votingv1.IsClosed = false;
                }
                int c = dc.SaveChanges();
                return c > 0;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }
 public static bool UpdatePoll(VotingClass poll)
 {
     var dc = new ManagementContext();
     try
     {
         var mem = RDN.Library.Classes.Account.User.GetMemberId();
         Guid lId = new Guid(poll.LeagueId);
         var voting = dc.Voting.Where(x => x.LeagueOwner.LeagueId == lId && x.VotingId == poll.VotingId).FirstOrDefault();
         voting.Question = poll.Question;
         voting.Description = poll.Description;
         int c = dc.SaveChanges();
         return c > 0;
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return false;
 }
        public static bool UpdatePollMobileAPI(VotingClass poll)
        {
            var dc = new ManagementContext();
            try
            {

                Guid lId = new Guid(poll.LeagueId);
                var voting = dc.VotingV2.Where(x => x.LeagueOwner.LeagueId == lId && x.VotingId == poll.VotingId).FirstOrDefault();
                voting.Title = poll.Title;
                voting.Description = poll.Description;
                voting.IsOpenToLeague = poll.IsOpenToLeague;

                ////question got deleted.
                //shouldn't be allowed to delete.
                //if (poll.Questions.Count != voting.Questions.Count)
                //{
                //    for (int k = 0; k < voting.Questions.Count; k++)
                //    {
                //        var aTemp = poll.Questions.Where(x => x.QuestionId == voting.Questions[k].QuestionId).FirstOrDefault();
                //        if (aTemp == null)
                //            voting.Questions[k].IsRemoved = true;
                //    }
                //}

                for (int i = 0; i < poll.Questions.Count; i++)
                {
                    var temp = voting.Questions.Where(x => x.QuestionId == poll.Questions[i].QuestionId).FirstOrDefault();
                    if (temp == null)
                    {
                        temp = new VotingQuestion();
                        temp.Question = poll.Questions[i].Question;
                        temp.QuestionSortId = voting.Questions.Count;
                        temp.QuestionType = (int)poll.Questions[i].QuestionType;
                        for (int j = 0; j < poll.Questions[i].Answers.Count; j++)
                        {
                            if (!String.IsNullOrEmpty(poll.Questions[i].Answers[j].Answer))
                            {
                                VotingAnswer answer = new VotingAnswer();
                                answer.Answer = poll.Questions[i].Answers[j].Answer;
                                answer.Question = temp;
                                temp.Answers.Add(answer);
                            }
                        }
                        voting.Questions.Add(temp);
                    }
                    else
                    {
                        temp.Question = poll.Questions[i].Question;
                        temp.QuestionSortId = i;
                        temp.QuestionType = (int)poll.Questions[i].QuestionType;

                        //answer got deleted
                        if (poll.Questions[i].Answers.Count != temp.Answers.Count)
                        {
                            for (int k = 0; k < temp.Answers.Count; k++)
                            {
                                var aTemp = poll.Questions[i].Answers.Where(x => x.AnswerId == temp.Answers[k].AnswerId).FirstOrDefault();
                                if (aTemp == null)
                                    temp.Answers[k].WasRemoved = true;
                            }
                        }

                        for (int j = 0; j < poll.Questions[i].Answers.Count; j++)
                        {
                            var tempAnswer = temp.Answers.Where(x => x.AnswerId == poll.Questions[i].Answers[j].AnswerId).FirstOrDefault();
                            if (tempAnswer == null)
                            {
                                if (!String.IsNullOrEmpty(poll.Questions[i].Answers[j].Answer))
                                {
                                    tempAnswer = new VotingAnswer();
                                    tempAnswer.Answer = poll.Questions[i].Answers[j].Answer;
                                    tempAnswer.Question = temp;
                                    temp.Answers.Add(tempAnswer);
                                }
                            }
                            else
                            {
                                tempAnswer.Answer = poll.Questions[i].Answers[j].Answer;
                            }
                        }

                    }
                }


                int c = dc.SaveChanges();
                return c > 0;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }
        public static PollBase GetPollsV2(Guid leagueId, Guid currentMemberId)
        {
            PollBase fact = new PollBase();
            var dc = new ManagementContext();
            try
            {
                var membersCount = MemberCache.GetLeagueMembers(currentMemberId, leagueId).Count;
                var voting = dc.VotingV2.Where(x => x.LeagueOwner.LeagueId == leagueId && x.IsDeleted == false).ToList();
                fact.IsPollManager = MemberCache.IsPollMgrOrBetterOfLeague(currentMemberId);
                fact.LeagueId = leagueId;
                for (int i = 0; i < voting.Count; i++)
                {
                    VotingClass v = new VotingClass();
                    v.CanEditPoll = fact.IsPollManager;
                    v.IsOpenToLeague = voting[i].IsOpenToLeague;
                    v.IsClosed = voting[i].IsClosed;
                    if (voting[i].Voters.Select(x => x.Member.MemberId).Contains(currentMemberId))
                    {
                        v.IsCurrentMemberAllowedToVote = true;
                    }
                    if (fact.IsPollManager || v.IsOpenToLeague)
                        v.CanViewPoll = true;
                    if (fact.IsPollManager || (v.IsCurrentMemberAllowedToVote && !v.IsClosed))
                        v.CanVotePoll = true;
                    //v.CanVotePoll = false;
                    //v.CanViewPoll = false;
                    //v.CanEditPoll = false;
                    v.Version = 2;
                    v.IsPublic = voting[i].IsPublic;
                    v.IsDeleted = voting[i].IsDeleted;
                    v.Question = voting[i].Title;
                    v.VotingId = voting[i].VotingId;
                    v.Created = voting[i].Created;
                    v.NonVotes = voting[i].Voters.Count;
                    if (voting[i].Questions.Count > 0)
                        v.Voted = voting[i].Questions.FirstOrDefault().Votes.Count;

                    fact.Polls.Add(v);
                }
                fact.Polls = fact.Polls.OrderByDescending(x => x.Created).ToList();
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return fact;
        }
        public static PollBase GetPollsNotVotedOn(Guid leagueId, Guid memId)
        {
            PollBase fact = new PollBase();
            var dc = new ManagementContext();
            try
            {
                var membersCount = MemberCache.GetLeagueMembers(memId, leagueId).Count;

                fact.LeagueId = leagueId;

                var votingV2 = dc.VotingV2.Where(x => x.LeagueOwner.LeagueId == leagueId && x.Voters.Select(y => y.Member.MemberId).Contains(memId) && x.IsClosed == false && x.IsDeleted == false && x.Questions.FirstOrDefault().Votes.Where(y => y.Member.MemberId == memId).Count() == 0).ToList();

                fact.LeagueId = leagueId;
                for (int i = 0; i < votingV2.Count; i++)
                {
                    VotingClass v = new VotingClass();
                    v.IsPublic = votingV2[i].IsPublic;
                    v.IsDeleted = votingV2[i].IsDeleted;
                    v.IsOpenToLeague = votingV2[i].IsOpenToLeague;
                    v.Title = votingV2[i].Title;
                    v.VotingId = votingV2[i].VotingId;
                    v.Version = 2;
                    fact.Polls.Add(v);
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return fact;
        }
 public ActionResult OpenPoll(VotingClass voting)
 {
     try
     {
         var poll = VotingFactory.OpenPoll(voting);
         return Redirect(Url.Content("~/poll/" + voting.LeagueId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.pc));
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
 }
        public ActionResult CreatePollAdd(VotingClass voting)
        {
            try
            {
                var mem = RDN.Library.Classes.Account.User.GetMemberId();
                var league = MemberCache.GetLeagueOfMember(mem);
                if (new Guid(voting.LeagueId) != league.LeagueId)
                    return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.na));

                for (int i = 0; i < 100; i++)
                {
                    if (!String.IsNullOrEmpty(HttpContext.Request["question" + i]))
                    {
                        VotingQuestionClass question = new VotingQuestionClass();
                        question.Question = HttpContext.Request["question" + i].ToString();
                        question.QuestionType = (QuestionTypeEnum)Enum.Parse(typeof(QuestionTypeEnum), HttpContext.Request["questiontype" + i].ToString());
                        for (int j = 1; j < 100; j++)
                        {
                            if (!String.IsNullOrEmpty(HttpContext.Request["answer-" + j + "-" + i]))
                            {
                                VotingAnswersClass answer = new VotingAnswersClass();
                                answer.Answer = HttpContext.Request["answer-" + j + "-" + i].ToString();
                                question.Answers.Add(answer);
                            }
                            else
                                break;
                        }
                        voting.Questions.Add(question);
                    }
                    else
                        break;
                }
                foreach (string guid in voting.ToMemberIds.Split(','))
                {
                    Guid temp = new Guid();
                    bool didWork = Guid.TryParse(guid, out temp);
                    if (didWork)
                        voting.Voters.Add(new MemberDisplayBasic() { MemberId = temp });
                }
                
                var poll = VotingFactory.AddPoll(voting, mem);
                return Redirect(Url.Content("~/poll/" + voting.LeagueId + "?u=" + SiteMessagesEnum.sag));
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
        }
        public ActionResult CreatePoll(string leagueId)
        {
            try
            {
                var mem = RDN.Library.Classes.Account.User.GetMemberId();
                var league = MemberCache.GetLeagueOfMember(mem);
                if (new Guid(leagueId) != league.LeagueId)
                    return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.na));

                VotingClass vc = new VotingClass();
                vc.LeagueName = league.Name;
                for (int i = 0; i < league.LeagueMembers.Count; i++)
                {
                    vc.Voters.Add(new MemberDisplayBasic()
                    {
                        MemberId = league.LeagueMembers[i].MemberId,
                        Firstname = league.LeagueMembers[i].Firstname,
                        LastName = league.LeagueMembers[i].LastName,
                        DerbyName = league.LeagueMembers[i].DerbyName
                    });
                }


                VotingQuestionClass q = new VotingQuestionClass();
                q.Answers.Add(new VotingAnswersClass());
                q.Answers.Add(new VotingAnswersClass());
                q.Answers.Add(new VotingAnswersClass());
                q.Answers.Add(new VotingAnswersClass());
                vc.Questions.Add(q);


                vc.LeagueId = leagueId;
                return View(vc);
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
        }
        public ActionResult VoteOnPollV2(VotingClass vote)
        {
            try
            {
                var mem = RDN.Library.Classes.Account.User.GetMemberId();
                var league = MemberCache.GetLeagueOfMember(mem);
                if (new Guid(vote.LeagueId) != league.LeagueId)
                    return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.na));

                var poll = VotingFactory.GetPollV2(league.LeagueId, vote.VotingId, mem);

                List<VotingQuestionClass> questions = new List<VotingQuestionClass>();
                foreach (var question in poll.Questions)
                {
                    VotingQuestionClass qu = new VotingQuestionClass();
                    qu.QuestionId = question.QuestionId;
                    var v = new VotesClass();
                    if (question.QuestionType == QuestionTypeEnum.Single)
                    {
                        if (!String.IsNullOrEmpty(HttpContext.Request.Form["answer-" + question.QuestionId]))
                        {
                            v.AnswerIds.Add(Convert.ToInt64(HttpContext.Request.Form["answer-" + question.QuestionId].ToString()));
                        }
                    }
                    else
                    {
                        foreach (var answer in question.Answers)
                        {
                            if (!String.IsNullOrEmpty(HttpContext.Request.Form["answer-" + question.QuestionId + "-" + answer.AnswerId]))
                            {
                                v.AnswerIds.Add(answer.AnswerId);
                            }
                        }
                    }
                    if (!String.IsNullOrEmpty(HttpContext.Request.Form["comment-" + question.QuestionId]))
                        v.OtherText = HttpContext.Request.Form["comment-" + question.QuestionId].ToString();
                    qu.Votes.Add(v);
                    questions.Add(qu);

                }

                var polls = VotingFactory.AddVoteV2(new Guid(vote.LeagueId), vote.VotingId, questions, mem);
                return Redirect(Url.Content("~/poll/" + vote.LeagueId + "?u=" + SiteMessagesEnum.sv));
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
        }
        public ActionResult VoteOnPoll(VotingClass vote)
        {
            try
            {
                var mem = RDN.Library.Classes.Account.User.GetMemberId();
                var league = MemberCache.GetLeagueOfMember(mem);
                if (new Guid(vote.LeagueId) != league.LeagueId)
                    return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.na));

                long answerId = Convert.ToInt64(Request.Form["AnswerType"]);


                var polls = VotingFactory.AddVote(new Guid(vote.LeagueId), Convert.ToInt64(vote.VotingId), mem, answerId, vote.Comment);
                if (polls == true)
                    return Redirect(Url.Content("~/poll/" + vote.LeagueId + "?u=" + SiteMessagesEnum.sv));
                else
                    return Redirect(Url.Content("~/poll/" + vote.LeagueId + "?u=" + SiteMessagesEnum.cl));
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
        }
        public ActionResult CreatePoll(string leagueId)
        {
            try
            {
                if (HttpContext.Request.InputStream != null)
                {
                    Stream stream = HttpContext.Request.InputStream;
                    var ob = Network.LoadObject<MemberPassParams>(ref stream);
                    var edit = MemberCache.GetMemberDisplay(ob.Mid);
                    if (ob.Uid == edit.UserId)
                    {
                        var league = MemberCache.GetLeagueOfMember(ob.Mid);

                        VotingClass vc = new VotingClass();
                        vc.LeagueName = league.Name;
                        for (int i = 0; i < league.LeagueMembers.Count; i++)
                        {
                            vc.Voters.Add(new MemberDisplayBasic()
                            {
                                MemberId = league.LeagueMembers[i].MemberId,
                                Firstname = league.LeagueMembers[i].Firstname,
                                LastName = league.LeagueMembers[i].LastName,
                                DerbyName = league.LeagueMembers[i].DerbyName
                            });
                        }
                        vc.IsSuccessful = true;
                        return Json(vc, JsonRequestBehavior.AllowGet);

                    }
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Json(new VotingClass() { IsSuccessful = false }, JsonRequestBehavior.AllowGet);
        }