public IEnumerable <ChallengeViewModel> GetChallengesForCurrentUser() { var currentUser = SessionManager.GetCurrentUser(); List <ChallengeViewModel> challenges = new List <ChallengeViewModel>(); foreach (Challenge challengeData in ChallengeAccess.GetChallengesForUser(currentUser.AthleteEmail)) { challenges.Add(CreateChallengeViewModel(challengeData)); } return(challenges); }
public NewChallengeViewModel CreateChallenge(NewChallengeViewModel newChallenge) { //TODO: // Add another table of emails to sync accounts for // we may need to do this when we sync someones friends try { var participantIds = new List <long>(); participantIds.Add(newChallenge.ChallengeeUserId); participantIds.Add(SessionManager.GetCurrentUser().UserId); if (ChallengeAccess.CreateChallenge(newChallenge.ToChallengeDataModel())) { return(newChallenge); } }catch (Exception e) { newChallenge.SetError("An error occured when trying to create your challenge."); } return(newChallenge); }