Esempio n. 1
0
        public IActionResult GetOrderByInstantCheckoutOrderId(Guid id, string fields = "")
        {
            if (!IsRequestAuthorized())
            {
                return(Unauthorized());
            }

            if (id == Guid.Empty)
            {
                return(Error(HttpStatusCode.BadRequest, "id", "invalid id"));
            }

            var order = _orderApiService.GetOrderByInstanCheckoutOrderId(id);

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

            var ordersRootObject = new OrdersRootObject();

            var orderDto = _dtoHelper.PrepareOrderDTO(order);

            ordersRootObject.Orders.Add(orderDto);

            var json = _jsonFieldsSerializer.Serialize(ordersRootObject, fields);

            return(new RawJsonActionResult(json));
        }