/// <summary> /// Provisions a new device in the platform. /// </summary> /// <param name="command">The command.</param> /// <returns></returns> public async Task ProvisionDevice(ProvisionDeviceCommand command) { // Do some business validation here. Make calls to the Query side to get additional domain info. // Send the command to the command bus await this.CommandBus.Send(command); }
public async Task <IActionResult> ProvisionDevice([FromBody] ProvisionDeviceCommand command) { try { // Check the model state and validate the integrity of the data if (ModelState.IsValid) { await this.DeviceService.ProvisionDevice(command); return(Accepted()); } return(HandleBadRequest()); } catch (Exception ex) { return(HandleError(ex)); } }