Пример #1
0
        public static Task <ServiceResult <CreateWidgetResponseDto> > CreateWidgetAsync(this IExampleApi service, WidgetDto widget, CancellationToken cancellationToken = default(CancellationToken))
        {
            var request = new CreateWidgetRequestDto {
                Widget = widget
            };

            return(service.CreateWidgetAsync(request, cancellationToken));
        }
Пример #2
0
        public async Task <ServiceResult <CreateWidgetResponseDto> > CreateWidgetAsync(CreateWidgetRequestDto request, CancellationToken cancellationToken)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (request.Widget == null)
            {
                return(ServiceResult.Failure(ServiceErrors.CreateRequestFieldRequired("widget")));
            }

            var newWidget = await m_repository.CreateWidgetAsync(request.Widget, cancellationToken).ConfigureAwait(false);

            return(ServiceResult.Success(new CreateWidgetResponseDto {
                Widget = newWidget
            }));
        }