public async Task <IActionResult> CreateGrade([FromBody] CreatingGradeModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var gradeId = await gradeService.CreateNew(model); if (gradeId == default(Guid)) { return(StatusCode(StatusCodes.Status422UnprocessableEntity)); } var gradeModel = await gradeService.FindById(gradeId); var student = await studentService.FindById(gradeModel.Student.Id); SMTPClient.ProfessorSendMail(gradeModel, student); return(StatusCode(StatusCodes.Status201Created)); }