public async System.Threading.Tasks.Task RunAsync([ServiceBusTrigger(Constants.SIGN_UP_FINISHED, Constants.ALL_MESSAGES_SUBSCRIPTION, Connection = Constants.SERVICE_BUS_CONNECTION_NAME)] SignUpProcessedMessage message, ILogger log)
        {
            log.LogInformation($"Sending email for sign up: {message}");

            var(courseId, student, _) = message;
            var course = await _coursesService.FindAsync(courseId);

            if (message.StudentAccepted)
            {
                _emailService.SendEmail(student.Email, ChamaSystemTexts.AcceptedIntoCourseTemplate(course, student));
            }
            else if (message.Status == SignUpStatus.CreditRefused)
            {
                _emailService.SendEmail(student.Email, ChamaSystemTexts.CreditRefusedCourseTemplate(course, student));
            }
            else
            {
                _emailService.SendEmail(student.Email, ChamaSystemTexts.NotAcceptedIntoCourseTemplate(course, student));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Post([FromBody] SignUpToCourseDto signUpToCourseDto)
        {
            await _messageBusService.SendToTopic(Constants.NEW_SIGN_UP_TOPIC, new NewSignUpMessage(signUpToCourseDto.CourseId, signUpToCourseDto.Student.ToDomain()));

            return(Ok(ChamaSystemTexts.NotifyUserThatTheyWillBeInformedByEmail(signUpToCourseDto.Student.Name)));
        }