예제 #1
0
        /// <inheritdoc/>
        public async Task <ServiceResult <OrderDto> > EditOrder(EditOrderRequest request)
        {
            var customer = await _context.Customers.FindAsync(request.CustomerId);

            if (customer == null)
            {
                var error = $"Пользователь с id = {request.CustomerId} не найден";
                _logger.LogError(error);
                return(new ServiceResult <OrderDto>(isSuccess: false, errors: new string[] { error }));
            }

            var order = customer.Orders.Where(o => o.Id == request.OrderNumber).FirstOrDefault();

            if (order == null)
            {
                var error = $"Заказ с номером {request.OrderNumber} не найден";
                _logger.LogError(error);
                return(new ServiceResult <OrderDto>(isSuccess: false, errors: new string[] { error }));
            }

            var errors = await EditOrder(order, request.Items);

            return(errors.Count != 0
                ? new ServiceResult <OrderDto>(item: _mapper.Map <OrderDto>(order), isSuccess: true, errors: errors.ToArray())
                : new ServiceResult <OrderDto>(item: _mapper.Map <OrderDto>(order), isSuccess: true));
        }
예제 #2
0
        protected IActionResult EditOrder(int orderId, EditOrderRequest editOrderRequest)
        {
            if (editOrderRequest == null)
            {
                return(BadRequest());
            }

            return(Ok(OrderBusiness.EditOrder(orderId, editOrderRequest.Quantity, editOrderRequest.Price, editOrderRequest.TakeProfit, editOrderRequest.StopLoss)));
        }
예제 #3
0
        public void Save(Order order, bool refresh)
        {
            var result = new EditOrderRequest(order, refresh).Execute(Api.Client);

            if (result.Status == 200)
            {
                order.Clean();
            }
        }
예제 #4
0
        public async Task <IActionResult> EditOrder([FromBody] EditOrderRequest request)
        {
            if (request == null || request?.CustomerId <= 0 || request?.OrderNumber <= 0 || request?.Items?.Length == 0)
            {
                return(BadRequest());
            }

            var result = await _orderService.EditOrder(request);

            return(Ok(result));
        }
예제 #5
0
        public string Edit(Order order)
        {
            string response = "";
            var    result   = new EditOrderRequest(order, false).Execute(Api.Client);

            if (result.Status == 200)
            {
                response = result.Data;
                order.Clean();
            }
            return(response);
        }
예제 #6
0
        public async Task Test_editorder()
        {
            //----------------------------------------------------------------------------
            // submit bid
            //----------------------------------------------------------------------------
            // form request
            BuySellRequest req = new BuySellRequest()
            {
                instrument_name = DeribitInstruments.Perpetual.BTCPERPETUAL,
                amount          = 10,
                type            = OrderType.limit,
                label           = "mylabel",
                price           = 1000,
                post_only       = true,
            };
            // execute
            BuySellResponse response = await this.deribit.Trading.Buy(req);

            Assert.That(response.order, Is.Not.Null);
            // wait
            await Task.Delay(1 << 9);

            //----------------------------------------------------------------------------
            // modify bid
            //----------------------------------------------------------------------------
            // form request
            EditOrderRequest req2 = new EditOrderRequest()
            {
                order_id = response.order.order_id,
                amount   = 20,
                price    = 500,
            };
            // execute request
            EditOrderResponse res2 = await this.deribit.Trading.EditOrder(req2);

            // assert
            var modifiedorder = res2.order;

            Assert.That(modifiedorder.order_id, Is.EqualTo(req2.order_id));
            Assert.That(modifiedorder.amount, Is.EqualTo(req2.amount));
            Assert.That(modifiedorder.price, Is.EqualTo(req2.price));
            //----------------------------------------------------------------------------
            // cleanup
            var response2 = await this.deribit.Trading.CancelAll();

            // assert
            Assert.That(response2.cancelledcount, Is.GreaterThan(0));
        }
예제 #7
0
        public ActionResult <string> EditOrderStatus([FromBody] EditOrderRequest request)
        {
            var resp = new CommonBaseInfo();

            #region 参数验证
            #endregion

            var id    = request.id.PackInt();
            var order = _context.Order.Where(m => m.id == id).FirstOrDefault();

            order.id     = request.id.PackInt();
            order.status = request.status.PackInt();
            if (request.driverId.PackInt() > 0)
            {
                order.driverId = request.driverId.PackInt();
            }
            var entry = _context.Attach(order);
            entry.State = EntityState.Unchanged;
            if (request.driverId.PackInt() > 0)
            {
                if (new OrderServices(_context).GetAllPassengerNum(order.driverId) + order.passengerNum > 3)
                {
                    resp.ResultMsg = "您超过最大载客数,无法接单";
                    resp.StateCode = 200;
                }
                entry.Property(p => p.driverId).IsModified = true;
            }
            //取消订单删除车主信息
            if (request.status.PackInt() == 0)
            {
                order.driverId = 0;
                entry.Property(p => p.driverId).IsModified = true;
            }
            entry.Property(p => p.status).IsModified = true;
            var result = _context.SaveChanges() > 0;
            if (result)
            {
                resp.ResultMsg = "修改成功";
                resp.StateCode = 200;
            }
            else
            {
                resp.ResultMsg = "修改失败";
                resp.StateCode = 400;
            }
            return(JsonConvert.SerializeObject(resp));
        }
예제 #8
0
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, EditOrderRequest model)
        {
            var orderRequest = OrderRequests.Find(item => item.OrderRequestId == model.OrderRequestId);

            if (orderRequest != null)
            {
                orderRequest.LastUpdate      = model.LastUpdate;
                orderRequest.BudgetYear      = model.BudgetYear;
                orderRequest.ReferenceNumber = model.ReferenceNumber;
                orderRequest.Department      = model.Department;
            }
            else
            {
                ModelState.AddModelError(string.Empty,
                                         String.Format("Could not find Order Request with id {0}", model.OrderRequestId));
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
예제 #9
0
        public async Task <IHttpActionResult> Edit([FromUri] Guid OrderId, [FromBody] EditOrderRequest request)
        {
            try
            {
                if (request.Amount <= 0)
                {
                    return(BadRequest());
                }

                var order = await _repository.Get <Order>(OrderId);

                if (order == null)
                {
                    return(NotFound());
                }

                order.ClientId    = request.ClientId;
                order.Description = request.Description;
                order.Amount      = request.Amount;

                var rows = await _repository.Save(order);

                if (rows == 0)
                {
                    return(BadRequest());
                }

                order = await _repository.Get <Order>(order.Id);

                var response = new EditOrderResponse
                {
                    Result = order
                };

                return(Ok(response));
            }
            catch (Exception)
            {
                // TODO: Log exception
            }
            return(InternalServerError());
        }
예제 #10
0
        public override async Task <PlaceOrderResponse> EditOrder(EditOrderRequest request, ServerCallContext context)
        {
            var cancelResult = await CancelOrder(new CancelOrderRequest { OrderId = request.OrderId }, context);

            if (cancelResult.ResultCase == CancelOrderResponse.ResultOneofCase.Error)
            {
                return(new PlaceOrderResponse {
                    Error = cancelResult.Error
                });
            }

            return(await PlaceLimitOrder(new LimitOrderRequest
            {
                AssetPairId = request.AssetPairId,
                AssetId = request.AssetId,
                Price = request.Price,
                Volume = request.Volume
            },
                                         context));
        }
예제 #11
0
        //[Authorize(Roles = "manager")]
        public async Task <IActionResult> EditOrder(int orderId, [FromBody] EditOrderRequest request)
        {
            await _orders.EditOrder(orderId, request.ProductsIds);

            return(NoContent());
        }
예제 #12
0
 public new IActionResult EditOrder([FromRoute] int orderId, [FromBody] EditOrderRequest editOrderRequest)
 {
     return(base.EditOrder(orderId, editOrderRequest));
 }