コード例 #1
0
        public IActionResult GetOrder([FromBody] GetOrderRequest request)
        {
            if (CheckToken(request, out CourierToken courierToken))
            {
                Order order = _context.Orders
                              .Include(o => o.Address)
                              .Include(o => o.Customer)
                              .Include(o => o.ProductOrders)
                              .ThenInclude(o => o.Product)
                              .AsNoTracking()
                              .FirstOrDefault(o => o.ID == request.OrderID);

                List <OrderProduct> orderProducts = new List <OrderProduct>();

                foreach (var po in order.ProductOrders)
                {
                    orderProducts.Add(new OrderProduct(po.Product)
                    {
                        Quantity = po.Quantity
                    });
                }

                OrderDetails orderDetails = new OrderDetails(order)
                {
                    OrderProducts = orderProducts
                };

                return(Ok(orderDetails));
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
コード例 #2
0
        public async Task PaymentCallBack(IFormCollection collection)
        {
            int             orderId = _paymentService.GetOrderIdFor(collection);
            GetOrderRequest request = new GetOrderRequest
            {
                OrderId = orderId
            };
            GetOrderResponse    response            = _orderService.GetOrder(request);
            OrderPaymentRequest orderPaymentRequest = _mapper.Map <OrderView, OrderPaymentRequest>(response.Order);
            TransactionResult   transactionResult   = await _paymentService.HandleCallBack(orderPaymentRequest, collection);

            if (transactionResult.PaymentOk)
            {
                SetOrderPaymentRequest paymentRequest = new SetOrderPaymentRequest();
                paymentRequest.Amount          = transactionResult.Amount;
                paymentRequest.PaymentToken    = transactionResult.PaymentToken;
                paymentRequest.PaymentMerchant = transactionResult.PaymentMerchant;
                paymentRequest.OrderId         = orderId;
                paymentRequest.CustomerEmail   = _cookieAuthentication.GetAuthenticationToken();

                _orderService.SetOrderPayment(paymentRequest);
            }
            else
            {
                _logger.LogWarning(string.Format("Payment not ok for order id {0}, payment token {1}", orderId, transactionResult.PaymentToken));
            }
        }
 public void GivenTheUserCreatesARequestToRetrieveTheDetailsOfAnOrderById(int orderId)
 {
     getOrderRequest = new GetOrderRequest(
         request,
         settings.OrderingApiBaseUrl,
         orderId);
 }
コード例 #4
0
 public List <WaveApi> GetWaveAPI(string domainName, string Processcenterid, DateTime DateS, DateTime DateE)
 {
     try
     {
         string url     = domainName + "/div/divide/getUnDividingOBPData";
         var    request = new GetOrderRequest
         {
             // Token = "5A9C85B6E068F2236A039E6157C5DF5B",
             processCenterId = Processcenterid,
             beginUpdateTime = DateS.ToString("yyyy-MM-dd HH:mm:ss"),
             endUpdateTime   = DateE.ToString("yyyy-MM-dd HH:mm:ss"),
         };
         var result = new Common.HttpHelper().Post <WaveApiResponse>(url, request);
         if (result.isSuccess)
         {
             return(result.data);
         }
         return(null);
     }
     catch (Exception ex)
     {
         log.Error("GetWaveAPI", ex);
         return(null);
     }
 }
コード例 #5
0
        private async Task <string> ProcessGetOrderRequest(GetOrderRequest request)
        {
            try
            {
                OrderDto orderDto = await _orderService.GetOrder(request.Order);

                string result;

                if (orderDto == null)
                {
                    WebMessageBase response = new WebMessageBase("get_order");
                    response.Status  = MessageStatus.FAIL;
                    response.Message = "Order with ID: " + request.Order + " not found";
                    result           = JsonConvert.SerializeObject(response, Formatting.Indented);
                    return(result);
                }

                OrderRequestResponse orderResponse = new OrderRequestResponse("get_order", orderDto.FromDto());
                result = JsonConvert.SerializeObject(orderResponse, Formatting.Indented);
                return(result);
            }
            catch (Exception e)
            {
                WebMessageBase response = new WebMessageBase();
                response.Status  = MessageStatus.FAIL;
                response.Message = "Could not get order !";
                string result = JsonConvert.SerializeObject(response, Formatting.Indented);
                _log("During processing get_order request an error occured: " + e.Message);
                return(result);
            }
        }
コード例 #6
0
        public override Task <GetOrderResponse> GetOrder(GetOrderRequest request, grpc::ServerCallContext context)
        {
            var response = new GetOrderResponse();

            var order = this.repository.GetOrder(request.OrderID);

            if (order != null)
            {
                response.OrderID   = order.OrderId;
                response.CreatedOn = (ulong)order.CreatedOn;
                response.TaxRate   = (uint)order.TaxRate;
                foreach (var li in order.LineItems)
                {
                    response.LineItems.Add(new LineItem
                    {
                        SKU       = li.SKU,
                        Quantity  = (uint)li.Quantity,
                        UnitPrice = (uint)li.UnitPrice,
                    });
                }
                var status = OrderStatus.Open;
                if (order.Activities.FirstOrDefault(a => a.ActivityType == ActivityType.Canceled) != null)
                {
                    status = OrderStatus.Canceled;
                }
                response.Status = status;
            }

            return(Task.FromResult(response));
        }
コード例 #7
0
        public async Task <IActionResult> GetOrderAsync(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "order/{orderId}")] GetOrderRequest req)
        {
            var order = await _orderService.GetOrderAsync(req);

            return(new OkObjectResult(order));
        }
コード例 #8
0
        public override async Task <GetOrderReply> GetOrder(GetOrderRequest request, ServerCallContext context)
        {
            var orders = GetOrders();
            var order  = orders.Find(x => x.Id == request.Id);

            return(order);
        }
コード例 #9
0
        public GetOrderResponse GetOrder(GetOrderRequest agor_gor)
        {
            GetOrderResponse lgor_response;

            lgor_response        = new GetOrderResponse();
            lgor_response.status = new Status();

            try
            {
                IOrderServiceBusiness liosb_iosb;

                liosb_iosb    = new OrderServiceBusiness();
                lgor_response = liosb_iosb.GetOrder(agor_gor);
            }
            catch (Exception ae_e)
            {
                Exception le_e;

                le_e = ae_e.InnerException != null ? ae_e.InnerException : ae_e;
                lgor_response.status.CodeResp    = "01";
                lgor_response.status.MessageResp = ae_e.InnerException != null ? "Error en la ejecucion del servicio" : ae_e.Message;
                lgor_response.result             = null;
                Common.CreateTrace.WriteLog(Common.CreateTrace.LogLevel.Error, "ERROR EN LA CAPA DE SERVICIO OrderService:GetOrder");
                Common.CreateTrace.WriteLog(Common.CreateTrace.LogLevel.Error, " :: " + le_e.Message);
            }

            return(lgor_response);
        }
コード例 #10
0
        public void GetOrderWithJsonServClt()
        {
            GetOrderRequest request = new GetOrderRequest
            {
                Id           = 1,
                CustomerName = "客户_1",
                //IsTakeAway = true,
                StatusCode  = StatusCode.Active,
                CreatedDate = DateTime.Now
            };

            OrderResponse response = null;

            using (JsonServiceClient client = new JsonServiceClient(listenOnUrl))
            {
                response = client.Get <OrderResponse>(request);
            }

            if (response != null)
            {
                response.PrintDump();
            }
            Console.WriteLine("成功获取指定的订单详情。");
            Console.ReadLine();
        }
コード例 #11
0
        public Order GetOrder(GetOrderRequest request)
        {
            // Create customer with circular reference
            //var cust = new Customer
            //{
            //    FirstName = "John",
            //    LastName = "Doe",
            //    DateOfBirth = DateTime.UtcNow
            //};
            //cust.Orders = new List<Order>
            //{
            //    new Order
            //    {
            //        OrderId = "abc123",
            //        DateTimePlaced = DateTime.UtcNow,
            //        Customer = cust,
            //    }
            //};

            var order = new Order
            {
                OrderId = request.OrderId,
                //Customer = cust,
                DateTimePlaced = DateTime.Now,
                Skus           = new List <string> {
                    "a1", "a2"
                }
            };

            return(order);
        }
コード例 #12
0
        public void PaymentCallBack(FormCollection collection)
        {
            int             orderId = _paymentService.GetOrderIdFor(collection);
            GetOrderRequest request = new GetOrderRequest()
            {
                OrderId = orderId
            };

            GetOrderResponse response = _orderService.GetOrder(request);

            OrderPaymentRequest orderPaymentRequest =
                response.Order.ConvertToOrderPaymentRequest();

            TransactionResult transactionResult =
                _paymentService.HandleCallBack(orderPaymentRequest, collection);

            if (transactionResult.PaymentOk)
            {
                SetOrderPaymentRequest paymentRequest = new SetOrderPaymentRequest();
                paymentRequest.Amount          = transactionResult.Amount;
                paymentRequest.PaymentToken    = transactionResult.PaymentToken;
                paymentRequest.PaymentMerchant = transactionResult.PaymentMerchant;
                paymentRequest.OrderId         = orderId;

                _orderService.SetOrderPayment(paymentRequest);
            }
            else
            {
                LoggingFactory.GetLogger().Log(String.Format(
                                                   "Payment not ok for order id {0}, payment token {1}",
                                                   orderId, transactionResult.PaymentToken));
            }
        }
コード例 #13
0
ファイル: OrderService.cs プロジェクト: kg73/BasicGrpcSample
        public Task <Order> GetOrderAsync(GetOrderRequest request)
        {
            // Create customer with circular reference
            var cust = new Customer
            {
                FirstName   = "John",
                LastName    = "Doe",
                DateOfBirth = DateTime.UtcNow
            };

            cust.Orders = new List <Order>
            {
                new Order
                {
                    OrderId        = "abc123",
                    DateTimePlaced = DateTime.UtcNow,
                    Customer       = cust,
                }
            };

            var order = new Order
            {
                OrderId        = request.OrderId,
                Customer       = cust,
                DateTimePlaced = DateTime.Now,
                Skus           = new List <string> {
                    "a1", "a2"
                }
            };

            return(Task.FromResult(order));
        }
コード例 #14
0
 public string InvokeGetOrder(List <string> amazonOrderIdList)
 {
     try
     {
         Console.WriteLine("Starting {0} at {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, DateTime.Now);
         // Create a request.
         GetOrderRequest request = new GetOrderRequest();
         request.SellerId      = api.SellerId;
         request.MWSAuthToken  = api.MWSAuthToken;
         request.AmazonOrderId = amazonOrderIdList;
         response = client.GetOrder(request);
         Console.WriteLine("Response:");
         rhmd = response.ResponseHeaderMetadata;
         // Is recommended logging the request id and timestamp of every call.
         Console.WriteLine("RequestId: " + rhmd.RequestId);
         Console.WriteLine("Timestamp: " + rhmd.Timestamp);
         string responseXml = response.ToXML();
         Console.WriteLine(responseXml);
         return(responseXml);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw ex;
     }
 }
コード例 #15
0
ファイル: OrderRepository.cs プロジェクト: pullig/Commerce
        public IEnumerable <Order> GetOrders(GetOrderRequest request)
        {
            var orders = context.Orders.AsQueryable();

            if (request.OrderId.HasValue)
            {
                orders = orders.Where(o => o.Id == request.OrderId);
            }

            if (!string.IsNullOrWhiteSpace(request.Username))
            {
                orders = orders.Where(o => o.User.Username.ToLower().Equals(request.Username.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(request.ProductName))
            {
                orders = orders.Where(o => o.Products.Any(p => p.Product.Name.ToLower().Equals(request.ProductName.ToLower())));
            }

            if (request.StartDate.HasValue)
            {
                orders = orders.Where(o => o.CreationDate.Date >= request.StartDate);
            }

            if (request.EndDate.HasValue)
            {
                orders = orders.Where(o => o.CreationDate.Date <= request.EndDate);
            }

            return(orders);
        }
コード例 #16
0
        /// <summary>
        /// 查询订单详情
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="openId"></param>
        /// <returns></returns>
        public HttpResponseMessage GetOrder([FromUri] GetOrderRequest request)
        {
            _logInfo.Info("获取订单详情请求" + Request.RequestUri);
            var viewModel = new OrderViewModel();

            if (!ModelState.IsValid)
            {
                viewModel.BusinessStatus = -10000;
                string msg = ModelState.Values.Where(item => item.Errors.Count == 1).Aggregate(string.Empty, (current, item) => current + (item.Errors[0].ErrorMessage + ";   "));
                viewModel.StatusMessage = "输入参数错误," + msg;
                return(viewModel.ResponseToJson());
            }
            try
            {
                var carOrder = _orderService.FindCarOrderBy(request, Request.GetQueryNameValuePairs()).ConvertToViewModel();
                _logInfo.Info("获取订单详情返回值" + carOrder.ToJson());
                if (carOrder != null)
                {
                    viewModel.CarOrder       = carOrder;
                    viewModel.BusinessStatus = 1;
                }
                else
                {
                    viewModel.BusinessStatus = -1;
                    viewModel.StatusMessage  = "无此订单信息";
                }
            }
            catch (Exception ex)
            {
                viewModel.BusinessStatus = -10002;
                viewModel.StatusMessage  = "查询订单列表失败";
            }
            return(viewModel.ResponseToJson());
        }
コード例 #17
0
ファイル: OrderService.cs プロジェクト: pullig/Commerce
        public IEnumerable <GetOrderResult> GetOrders(GetOrderRequest request)
        {
            var orders = orderRepository.GetOrders(request);

            var result = mapper.Map <IEnumerable <GetOrderResult> >(orders.ToList());

            return(result);
        }
コード例 #18
0
        public GetOrderResponse GetOrder(GetOrderRequest request)
        {
            GetOrderResponse response = new GetOrderResponse();
            Order            order    = _orderRepository.FindBy(request.OrderId);

            response.Order = _mapper.Map <Order, OrderView>(order);

            return(response);
        }
コード例 #19
0
        public ActionResult <GetOrderResponse> GetOrder(long id)
        {
            var request = new GetOrderRequest {
                Id = id
            };
            var response = _service.GetOrder(request);

            return(response);
        }
コード例 #20
0
ファイル: OrderService.cs プロジェクト: hzl091/MyFX
        public GetOrderResult GetOrder(GetOrderRequest request)
        {
            var            order = _orderRepository.First(o => o.OrderNo.Equals(request.OrderNo));
            GetOrderResult rs    = new GetOrderResult();

            rs.Data = order;

            return(rs);
        }
コード例 #21
0
        public override async Task <GetOrderResponse> GetOrder(GetOrderRequest request, ServerCallContext context)
        {
            var order = await _ordersRepository.GetAsync(Guid.Parse(request.Id));

            return(new GetOrderResponse()
            {
                Item = GrpcMapper.MapOrder(order)
            });
        }
コード例 #22
0
ファイル: AdminService.cs プロジェクト: fferragina/Fallstudie
        public GetOrderResponse GetOrderById(GetOrderRequest request)
        {
            GetOrderResponse       response = new GetOrderResponse();
            OrderBusinessComponent bc       = DependencyInjectionHelper.GetOrderBusinessComponent();

            response.Order = OrderAdapter.OrderToDto(bc.GetOrderById(request.Id));

            return(response);
        }
コード例 #23
0
ファイル: OrderManager.cs プロジェクト: radtek/Convenience
        public GetTransferOrderResponse GetTransferOrderDetail(string orderid, string memberid)
        {
            GetOrderCondition info = new GetOrderCondition()
            {
                memberId = memberid, orderId = orderid
            };
            var password = GetPassword(info.memberId);
            var datetime = DateTime.Now;
            var request  = new GetOrderRequest
            {
                dataMap = info,
                sign    = BuildSign(info, datetime, password),
                reqTime = datetime.ToString(DateTimeFormat)
            };
            var jSetting = new JsonSerializerSettings();

            jSetting.NullValueHandling = NullValueHandling.Ignore;
            var content = JsonConvert.SerializeObject(request, jSetting);

            _log.Debug("Post data:" + content);
            var config = new CommonConfig(null);

            var req = (HttpWebRequest)WebRequest.Create(config.JavaOrder_Uri + "queryOrdersById");

            req.Method      = "POST";
            req.ContentType = "Application/Json";
            req.Credentials = CredentialCache.DefaultCredentials;
            req.Timeout     = 300000;
            // 如果服务器返回错误,他还会继续再去请求,不会使用之前的错误数据,做返回数据
            //req.ServicePoint.Expect100Continue = false;
            WriteRequestData(req, content);
            var response = req.GetResponse();

            if (response == null)
            {
                throw new Exception("请求失败!");
            }
            var stream = response.GetResponseStream();

            if (stream == null)
            {
                throw new Exception("请求Stream为空!");
            }
            var sr     = new StreamReader(stream, Encoding.UTF8);
            var retXml = sr.ReadToEnd();

            sr.Close();
            _log.Debug(retXml);
            var obj = JsonConvert.DeserializeObject <GetTransferOrderResponse>(retXml);

            if (obj.respCode != "0")
            {
                throw new ApplicationException(obj.respMsg);
            }
            return(obj);
        }
コード例 #24
0
        public ActionResult <GetOrderResponse> GetOrder(long id)
        {
            var getRequest = new GetOrderRequest
            {
                Id = id
            };
            var getResponse = _orderService.GetOrder(getRequest);

            return(getResponse);
        }
コード例 #25
0
        public IActionResult GetOrders(GetOrderRequest request)
        {
            var res = _orderServiceDb.GetOrders(request);

            if (res == null)
            {
                return(BadRequest());
            }
            return(Ok(res));
        }
コード例 #26
0
        public GetOrderResponse GetOrder(GetOrderRequest request)
        {
            GetOrderResponse response = new GetOrderResponse();

            Order order = _orderRepository.FindBy(request.OrderId);

            response.Order = order.ConvertToOrderView();

            return(response);
        }
コード例 #27
0
        public List <Order> ListSpecificOrders(IEnumerable <string> orderIds)
        {
            var request = new GetOrderRequest
            {
                SellerId      = _amazonSellerSettings.SellerId,
                AmazonOrderId = new OrderIdList().WithId(orderIds.Select(x => x).ToArray())
            };

            return(GetOrder(request));
        }
コード例 #28
0
ファイル: BinanceClient.cs プロジェクト: razvm/binance.net
        public async Task <Order> GetOrder(string symbol, string origClientOrderId = null, long?orderId = null)
        {
            var req = new GetOrderRequest()
            {
                Symbol = symbol, OrigClientOrderId = origClientOrderId, OrderId = orderId
            };
            var resp = await _connecter.PrivateRequest(req);

            return(JsonConvert.DeserializeObject <Order>(resp.Content));
        }
コード例 #29
0
ファイル: OrderService.cs プロジェクト: ercinakyuz/automat
        public async Task <GetOrderResponse> GetOrderAsync(GetOrderRequest request, CancellationToken cancellationToken)
        {
            var order = await _orderRepository.GetByIdAsync(request.OrderId);

            return(new GetOrderResponse
            {
                Basket = order.Basket,
                Payment = order.Payment
            });
        }
コード例 #30
0
        public GetOrderRespose WorkOrderProcess(GetOrderRequest GOR)
        {
            GetOrderRespose SM = new GetOrderRespose();

            try
            {
                if (GOR.UserId == "" || GOR.UserId == null)
                {
                    SM.Status  = "Failure";
                    SM.Message = "Enter UserId";
                    return(SM);
                }
                if (GOR.WorkOrderNo == "" || GOR.WorkOrderNo == null)
                {
                    SM.Status  = "Failure";
                    SM.Message = "Invalid WorkOrderNo";
                    return(SM);
                }

                query     = "Sp_WorkOrderWebApi";
                dbcommand = new SqlCommand(query, conn);
                dbcommand.Connection.Open();
                dbcommand.CommandType = CommandType.StoredProcedure;
                dbcommand.Parameters.AddWithValue("@QueryType", "WorkOrderProcess");
                dbcommand.Parameters.AddWithValue("@WorkOrderNo", GOR.WorkOrderNo);
                dbcommand.Parameters.AddWithValue("@UserId", GOR.UserId);
                dbcommand.CommandTimeout = 0;
                SqlDataAdapter da = new SqlDataAdapter(dbcommand);
                DataTable      dt = new DataTable();
                da.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    SM.WorkOrderId = dt.Rows[0]["WorkOrderId"].ToString();
                    SM.WorkOrderNo = dt.Rows[0]["WorkOrderNo"].ToString();
                    SM.Status      = "Success";
                    SM.Message     = "Record Found";
                }
                else
                {
                    SM.Status  = "Failure";
                    SM.Message = "Invalid WorkOrder No";
                    return(SM);
                }
            }
            catch (Exception Ex)
            {
                SM.Status  = "Failure";
                SM.Message = Ex.Message;
            }
            //finally
            //{
            //    //dbcommand.Connection.Close();
            //}
            return(SM);
        }
コード例 #31
0
        public GetOrderResponse GetOrder(GetOrderRequest request)
        {
            var order = _repository.GetOrder(request.Id);

            var response = new GetOrderResponse()
            {
                Order = OrderApiDto.FromDomain(order)
            };

            return response;
        }