public async Task <bool> SignUpStudentAsync(int courseId, string studentId) { var courseInfo = await this.GetCourseStudentInfo(courseId, studentId); if (courseInfo == null || courseInfo.StartDate < DateTime.UtcNow || courseInfo.StudentIsEnrolledInCourse) { return(false); } var studentInCourst = new StudentCourse { CourseId = courseId, StudentId = studentId }; await db.AddAsync(studentInCourst); await db.SaveChangesAsync(); return(true); }
public async Task <bool> SignUpStudentAsync(int courseId, string userId) { var courseInfo = await GetCourseInfo(courseId, userId); if (courseInfo == null || courseInfo.StartDate < DateTime.UtcNow.Date || courseInfo.IsStudentEnrolledInCourse) { return(false); } var studentInCourse = new StudentCourse { CourseId = courseId, StudentId = userId }; await _dbContext.AddAsync(studentInCourse); await _dbContext.SaveChangesAsync(); return(true); }