Example #1
0
 public async Task <bool> RegisterStudent(StudentSignUp studentSignUp)
 {
     using (var context = new LearningFivesEntities())
     {
         context.StudentSignUps.Add(studentSignUp);
         return(await context.SaveChangesAsync() > 0);
     }
 }
Example #2
0
 public async Task <bool> RegisterCoach(CoachSignUp coachSignUp)
 {
     using (var context = new LearningFivesEntities())
     {
         context.CoachSignUps.Add(coachSignUp);
         return(await context.SaveChangesAsync() > 0);
     }
 }
Example #3
0
        public async Task <CoachPlayer> RemoveStudentFromCoachAsync(int coachSignUpId, int studentSignUpId)
        {
            using (var context = new LearningFivesEntities())
            {
                var coachPlayer = context.CoachPlayers.FirstOrDefault(i => i.CoachSignUpID == coachSignUpId && i.StudentSignUpID == studentSignUpId);
                if (coachPlayer == null)
                {
                    return(null);
                }

                var result = context.CoachPlayers.Remove(coachPlayer);
                await context.SaveChangesAsync();

                return(result);
            }
        }
Example #4
0
        public async Task <CoachPlayer> AddStudentToCoachAsync(int coachSignUpId, int studentSignUpId)
        {
            using (var context = new LearningFivesEntities())
            {
                var teamSize = await context.CoachPlayers.Where(i => i.CoachSignUpID == coachSignUpId).CountAsync();

                if (teamSize >= TeamSizeLimit)
                {
                    return(null);
                }

                var coachPlayer = context.CoachPlayers.Add(new CoachPlayer
                {
                    CoachSignUp   = context.CoachSignUps.FirstOrDefault(i => i.CoachSignUpID == coachSignUpId),
                    StudentSignUp = context.StudentSignUps.FirstOrDefault(i => i.StudentSignUpID == studentSignUpId)
                });

                await context.SaveChangesAsync();

                return(coachPlayer);
            }
        }