Advertisement
yuvarajupadhyaya

GetCoursesByGrades Backup

Jan 30th, 2023
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | Source Code | 0 0
  1.  //int[] GradeID
  2.         [Authorize(Roles = "Instructor")]
  3.         [HttpGet("GetCoursesByGrades")]
  4.         public async Task<object> GetCoursesByGrades([ModelBinder(BinderType = typeof(MultipartModelBinder))] ClassRoomVM postData)
  5.         {
  6.             try
  7.             {
  8.                 List<int> neemaGradeIds = await UnitOfWork.InstituteGradeRepository.Get(x => postData.GradeID.Contains(x.GradeID))
  9.                     .Select(x => x.NeemaGradeID).ToListAsync();
  10.  
  11.                 var courses = await UnitOfWork.CourseRepository.Get(c => c.IsActive && !c.IsDeleted && c.CourseGrade.Any(x=> neemaGradeIds.Contains(x.GradeID)))
  12.                     .Select(x=>new
  13.                     {
  14.                         CourseID=x.CourseID,
  15.                         CourseName=x.CourseName
  16.                     })
  17.               .ToListAsync();
  18.  
  19.                
  20.  
  21.                 return ApiResultHelper.CreateApiResult(this, success: true, message: "Got Courses By Grades successfully.", result: courses);
  22.             }
  23.             catch (Exception ex)
  24.             {
  25.                 TheLogger.Log("ClassRoomController", LogLevel.Error, "GetCoursesByGrades " + ex.Message, ex: ex);
  26.                 return ApiResultHelper.CreateApiResult(this, success: false, message: "Failed to Got Courses By Grades.", statusCode: System.Net.HttpStatusCode.InternalServerError);
  27.             }
  28.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement