Beispiel #1
0
        public async Task <IActionResult> GetCustomerById(int id, string fields = "")
        {
            if (id <= 0)
            {
                return(Error(HttpStatusCode.BadRequest, "id", "invalid id"));
            }

            var customer = await _customerApiService.GetCustomerByIdAsync(id);

            if (customer == null)
            {
                return(Error(HttpStatusCode.NotFound, "customer", "not found"));
            }

            var customersRootObject = new CustomersRootObject();

            customersRootObject.Customers.Add(customer);

            var json = JsonFieldsSerializer.Serialize(customersRootObject, fields);

            return(new RawJsonActionResult(json));
        }