Exemplo n.º 1
0
        public async Task <IActionResult> Post([FromBody] JobApplicant model)
        {
            // fetch the job data
            var job = await _jobRepository.Get(model.JobId);

            var id = await _jobRepository.AddApplicant(model);

            //var endpoint = await _bus.GetSendEndpoint(new Uri("rabbitmq://rabbitmq/dotnetgigs"));  //?bind=true&queue=dotnetgigs
            //await endpoint.Send<ApplicantAppliedEvent>(new  { model.JobId,model.ApplicantId,job.Title});
            await _bus.Publish <ApplicantAppliedEvent>(new { model.JobId, model.ApplicantId, job.Title });

            return(Ok(id));
        }
        public async Task <IActionResult> Post([FromBody] JobApplicant model)
        {
            // fetch the job data
            var job = await _jobRepository.Get(model.JobId);

            var id = await _jobRepository.AddApplicant(model);

            // commands should be sent to specific endpoint:
            //var endpoint = await _bus.GetSendEndpoint(new Uri("rabbitmq://rabbitmq/dncmt"));  //?bind=true&queue=dncmt
            //await endpoint.Send<ApplicantApplyCommand>(new  { model.JobId,model.ApplicantId,job.Title});

            // events should be published widely:
            await _bus.Publish <ApplicantAppliedEvent>(new { model.JobId, model.ApplicantId, job.Title });

            return(Ok(id));
        }