public async Task When_EvaluatingTutoringSession_Expect_SessionEvaluated() { _currentUserServiceMock .Setup(s => s.GetUserId()) .Returns(_userManager.Users.First(u => u.Email == "*****@*****.**").Id); var evaluation = new TutoringSessionEvaluationDto { Evaluation = TutoringSessionEvaluationEnum.Good, Comment = "Lacked charisma" }; await _tutoringSessionsService.EvaluateTutoringSession(3, evaluation); var session = await _context.TutoringSessions.FirstAsync(ts => ts.Id == 3); Assert.Equal(TutoringSessionEvaluationEnum.Good, session.Evaluation); Assert.Equal("Lacked charisma", session.EvaluationComment); }
public async Task <IActionResult> EvaluateTutoringSession(int id, [FromBody] TutoringSessionEvaluationDto tutoringEvaluation) { try { var aggregate = await _tutoringSessionsService.EvaluateTutoringSession(id, tutoringEvaluation); Response.OnCompleted(async() => await _emailService.SendTutoringSessionEvaluatedEmail(aggregate) ); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }