public async Task CreateOrder()
        {
            await _ordersService.CreateAsync();

            await Task.Delay(1000);

            _uriHelper.NavigateTo("/orders");
        }
示例#2
0
        public async Task <ActionResult <Guid> > Create(Order order, CancellationToken ct = default)
        {
            order.AccountId = _userContext.AccountId;

            var id = await _ordersService.CreateAsync(_userContext.UserId, order, ct);

            return(Created(nameof(Get), id));
        }
示例#3
0
        public async Task <ActionResult> Post(CreateOrder request)
        {
            try
            {
                await _ordersService.CreateAsync(request);

                return(CreatedAtAction(nameof(Get), new { id = request.Id }, null));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
示例#4
0
        public async Task HandleAsync(CreateOrder command)
        {
            var cart = await _cartService.GetAsync(command.CustomerId);

            var productIds = cart.Items.Select(i => i.ProductId);
            var products   = await _productsService.GetAsync(productIds);

            var totalAmount = products.Sum(p =>
            {
                var quantity = cart.Items.FirstOrDefault(i => i.ProductId == p.Id).Quantity;
                return(quantity * p.Price);
            });
            var orderNumber = new Random().Next();
            await _ordersService.CreateAsync(command.Id, command.CustomerId, orderNumber, productIds, totalAmount, "USD");
        }
示例#5
0
        public async Task <OrderModel> CreateOrderAsync([FromBody] CreateOrderModel model)
        {
            try
            {
                var order = await _ordersService.CreateAsync(model.WalletId, model.PriceId, model.QuotingVolume);

                return(Mapper.Map <OrderModel>(order));
            }
            catch (EntityNotFoundException)
            {
                throw new ValidationApiException(HttpStatusCode.NotFound, "Price snapshot does not exist.");
            }
            catch (FailedOperationException exception)
            {
                _log.Error(exception);

                throw new ValidationApiException(HttpStatusCode.BadRequest, exception.Message);
            }
        }
示例#6
0
        public async Task <BaseResponseModel> CreateAsync([FromBody] OrderModel orderModel)
        {
            BaseResponseModel report = await _service.CreateAsync(orderModel);

            return(report);
        }
 public async Task <IActionResult> Create(OrderVm model)
 {
     model.UserId = User.Identity.GetUserId();
     return((await _ordersService.CreateAsync(model))
            .Match(RedirectToConfirmation, RedirectToIndexWithErrMsg));
 }