Example #1
0
        //ANCHOR Creates a new base challenge
        internal RuleDetails Create(Profile user, RuleDetails newRule)
        {
            Challenge challenge = _cRepo.GetById(newRule.ChallengeId);

            if (challenge.Joinable == true || challenge.HasStarted == true)
            {
                throw new Exception("This Challenge has already been finalized");
            }
            if (user.Id != challenge.CreatorId)
            {
                throw new Exception("This Is Not Yours");
            }
            newRule.Id = _repo.CreateNewRule(newRule);
            return(newRule);
        }
Example #2
0
        //ANCHOR Creates a new Participant with a Pending acception status
        //ANCHOR Checks
        internal Participant Create(Participant newParticipant)
        {
            Challenge currentChallenge = _cs.GetById(newParticipant.ChallengeId.ToString());

            if (currentChallenge.HasStarted == true)
            {
                throw new Exception("This Challenge has already started");
            }
            if (currentChallenge.Joinable == false)
            {
                throw new Exception("This Challenge is not yet joinable");
            }
            List <Participant> participantList = _repo.GetAllParticipantsByChallengeId(newParticipant.ChallengeId).ToList();

            for (int i = 0; i < participantList.Count; i++)
            {
                if (participantList[i].ProfileId == newParticipant.ProfileId && participantList[i].PendingAddToChallenge == true || participantList[i].ProfileId == newParticipant.ProfileId && participantList[i].AddedToChallenge == true)
                {
                    throw new Exception("Participant already exists");
                }
            }
            newParticipant.Id = _repo.Create(newParticipant);
            return(newParticipant);
        }
Example #3
0
        internal IEnumerable <DailyPoints> GetDpsByChallengeId(Profile userInfo, string challengeId)
        {
            Challenge challenge = _cs.GetById(challengeId);

            return(_repo.GetDpsByChallengeId(challenge.Id.ToString(), userInfo.Id));
        }