public async Task <ActionResult <string> > Patch( [FromBody] JsonPatchDocument <UpdateAppointmentCommand.Command> commandPatch, string id) { var appointment = await _mediator.Send(new GetAppointmentQuery.Query { Id = id }); if (appointment != null) { var command = new UpdateAppointmentCommand.Command(); command.Id = id; command.Comments = appointment.Comments; command.Place = appointment.Place; command.Description = appointment.Description; command.DateTime = appointment.DateTime; commandPatch.ApplyTo(command, ModelState); if (ModelState.IsValid) { await _mediator.Send(command); } else { var serializableModelState = new SerializableError(ModelState); var modelStateJson = JsonConvert.SerializeObject(serializableModelState); return(BadRequest(modelStateJson)); } return(Ok(id)); } return(NotFound()); }
public async Task <ActionResult <string> > Put(UpdateAppointmentCommand.Command command) { var result = await _mediator.Send(command); return(Ok(result)); }