private void PublishCreateConsultationCommand() { var id = ConsultationId.New; var command = new CreateConsultationCommand(id, _state.PatientId, _state.DoctorId, _state.TreatmentRoomId, _state.PatientRegistrationDate, _state.ConsultationDate.Value); this.Publish(command); }
public async Task <IActionResult> Post([FromHeader] Guid userId, [FromBody] CreateConsultationCommand command) { var consultationId = await consultationLogic.SaveConsultation(command); if (consultationId == Guid.Empty) { return(BadRequest()); } return(CreatedAtAction(nameof(GetConsultation), new { id = consultationId }, consultationId)); }
public async Task <Guid> SaveConsultation(CreateConsultationCommand command) { var consultation = mapper.Map <Entities.Consultation>(command); consultation.Id = Guid.NewGuid(); consultation.IsActive = true; consultation.Created = DateTime.UtcNow; consultation.CreatedBy = command.CreatedBy; consultation.Updated = DateTime.UtcNow; consultation.UpdatedBy = command.CreatedBy; await context.Consultation.AddAsync(consultation); var rowChanged = await context.SaveChangesAsync(); if (rowChanged == 0) { return(Guid.Empty); } return(consultation.Id); }
public async Task <ActionResult <int> > Create([FromBody] CreateConsultationCommand command) { var newId = await Mediator.Send(command); return(CreatedAtAction(nameof(Get), new { id = newId }, newId)); }