Beispiel #1
0
 public OrderGraphType(ICustomerServices customerServices)
 {
     Field(x => x.Id);
     Field(x => x.Name);
     Field <CustomerGraphType>("Customer",
                               resolve: context =>
                               customerServices.GetCustomerByIdAsync(context.Source.CustomerId));
     Field(x => x.DateTime);
     //Field(x => x.Amount);
     Field(x => x.Description);
     Field <OrderStatusesEnum>("status",
                               resolve: context => context.Source.Status);
 }
        public async Task <IActionResult> CustomerByIdAsync([FromQuery] Guid id, CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var request = new CustomerRequest
            {
                Id = id
            };

            var customer = await _customerServices.GetCustomerByIdAsync(request, cancellationToken);

            if (customer == null)
            {
                return(NoContent());
            }

            return(Ok(customer));
        }