public async Task <IActionResult> RegisterNewInfectedApplicant([FromBody] RegisterNewApplicantBindingModel bm) { if (!ModelState.IsValid) { return(StatusCode(400, "Model state is not valid")); } this.applicantBusService.MessageApplicantAPI_RegisterNewApplicant(bm); return(StatusCode(202)); // Accepted }
public async Task CreateApplicantRegistration(RegisterNewApplicantBindingModel bm) { // let's assume that the object is much bigger, so we can use automapper here to map the binding model to entity model var newApplicant = new Applicant() { FirstName = bm.FirstName, LastName = bm.LastName, Email = bm.Email, Age = bm.Age, Symptoms = bm.Symptoms, RegisteredOn = DateTime.UtcNow }; this.Context.Applicants.Add(newApplicant); await this.Context.SaveChangesAsync(); }
public async Task Consume(ConsumeContext <IRegisterNewApplicant> context) { var message = context.Message; // assume the object is bigger.. we can use automapper in this case var newApplicant = new RegisterNewApplicantBindingModel() { FirstName = message.FirstName, LastName = message.LastName, Email = message.Email, Age = message.Age, Symptoms = message.Symptoms }; await this.applicantService.CreateApplicantRegistration(newApplicant); this.notificationBusService.MessageNotificationAPI_SendEventNotification($"Congrats {newApplicant.FirstName}, you are successfully registered!"); }
public async Task MessageApplicantAPI_RegisterNewApplicant(RegisterNewApplicantBindingModel bm) { var endpoint = await this.bus.GetSendEndpoint(new Uri("queue:register-new-applicant-queue")); await endpoint.Send <IRegisterNewApplicant>(bm); }