public async Task <IActionResult> GetSingleMeeting([FromRoute] int meetingId) { int parentId = GetUserId(); IOperationResult <Meeting> result = await _meetingsManager.GetMeetingForParent(meetingId, parentId); if (!result.Success) { return(BadRequest(result.Message)); } var mapped = _mapper.Map <ParentMeetingResponse>(result.Entity); mapped.Student.Ratings = _ratingManager.GetUserAvgRatings(mapped.Student.Id); mapped.Tutor.Ratings = _ratingManager.GetUserAvgRatings(mapped.Tutor.Id); return(Ok(mapped)); }
public async Task <IActionResult> GetTutorsForSubject([FromRoute] int subjectId) { IOperationResult <ISet <User> > result = await _tutorsManager.GetTutorsBySubjectId(subjectId); if (!result.Success) { return(BadRequest(result.Message)); } var tutors = _mapper.Map <ISet <TutorSimpleResponse> >(result.Entity); IEnumerable <TutorSimpleResponse> mapped = tutors.Select(t => { t.Ratings = _ratingManager.GetUserAvgRatings(t.Id); return(t); }); return(Ok(mapped)); }
public async Task <IActionResult> GetMeetingSummary([FromRoute] int meetingId) { int userId = GetUserId(); IOperationResult <Meeting> operationResult = await _meetingsManager.GetMeeting(meetingId, userId); if (!operationResult.Success) { return(BadRequest(operationResult.Message)); } MeetingSummaryModel mapped = _mapper.Map <MeetingSummaryModel>(operationResult.Entity); mapped.StudentRatings = _ratingManager.GetUserAvgRatings(mapped.StudentId); mapped.TutorRatings = _ratingManager.GetUserAvgRatings(mapped.TutorId); return(Ok(mapped)); }
public async Task <IActionResult> GetNotSelectedTutorsInMeetingForStudent([FromRoute] int meetingId) { IOperationResult <ISet <User> > operationResult = await _tutorsManager.GetTutorNotInCurMeeting(meetingId); if (!operationResult.Success) { return(BadRequest(operationResult.Message)); } ISet <TutorSimpleResponse> tutors = _mapper.Map <ISet <TutorSimpleResponse> >(operationResult.Entity); IEnumerable <TutorSimpleResponse> mapped = tutors.Select(t => { t.Ratings = _ratingManager.GetUserAvgRatings(t.Id); return(t); }); return(Ok(tutors)); }
public async Task <IActionResult> GetUserProfile() { var userId = GetUserId(); IOperationResult <User> operationResult = await _usersManager.GetUserProfile(userId); if (!operationResult.Success) { return(BadRequest(operationResult.Message)); } UserResponse user = _mapper.Map <UserResponse>(operationResult.Entity); user.Ratings = _ratingManager.GetUserAvgRatings(userId); return(Ok(user)); }