Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //int[] GradeID
- [Authorize(Roles = "Instructor")]
- [HttpGet("GetCoursesByGrades")]
- public async Task<object> GetCoursesByGrades([ModelBinder(BinderType = typeof(MultipartModelBinder))] ClassRoomVM postData)
- {
- try
- {
- List<int> neemaGradeIds = await UnitOfWork.InstituteGradeRepository.Get(x => postData.GradeID.Contains(x.GradeID))
- .Select(x => x.NeemaGradeID).ToListAsync();
- var courses = await UnitOfWork.CourseRepository.Get(c => c.IsActive && !c.IsDeleted && c.CourseGrade.Any(x=> neemaGradeIds.Contains(x.GradeID)))
- .Select(x=>new
- {
- CourseID=x.CourseID,
- CourseName=x.CourseName
- })
- .ToListAsync();
- return ApiResultHelper.CreateApiResult(this, success: true, message: "Got Courses By Grades successfully.", result: courses);
- }
- catch (Exception ex)
- {
- TheLogger.Log("ClassRoomController", LogLevel.Error, "GetCoursesByGrades " + ex.Message, ex: ex);
- return ApiResultHelper.CreateApiResult(this, success: false, message: "Failed to Got Courses By Grades.", statusCode: System.Net.HttpStatusCode.InternalServerError);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement