public static Model.DriverCreationInfo Convert(Client.DriverCreationInfo clientCreationInfo)
        {
            if (clientCreationInfo == null)
            {
                throw new ArgumentNullException(nameof(clientCreationInfo));
            }

            var modelCreationInfo = new Model.DriverCreationInfo(clientCreationInfo.Name,
                                                                 clientCreationInfo.SerialNumberPass, clientCreationInfo.PhoneNumber);

            return(modelCreationInfo);
        }
예제 #2
0
        public async Task <IActionResult> CreateDriverAsync([FromBody] Client.DriverCreationInfo creationInfo,
                                                            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (creationInfo == null)
            {
                var error = ErrorResponsesService.BodyIsMissing(nameof(creationInfo));
                return(BadRequest(error));
            }

            var modelCreationInfo = Converter.DriverCreationInfoConverter.Convert(creationInfo);
            var modelDriver       = await repository.CreateAsync(modelCreationInfo, cancellationToken).ConfigureAwait(false);

            var clientDriver = Converter.DriverConverter.Convert(modelDriver);

            return(CreatedAtRoute("GetDriverRoute", new { id = clientDriver.Id }, clientDriver));
        }