コード例 #1
0
        /// <summary>
        /// Handler which processes the command when
        /// customer executes cancel order from app
        /// </summary>
        /// <param name="command"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <ObjectId> HandleAsync(CreateOrderCommand command, CancellationToken cancellationToken)
        {
            var order = new Order(
                command.UserId,
                new Address(command.Street, command.City, command.State, command.Country, command.ZipCode),
                command.Description,
                command.OrderItems.Select(x => x.ToOrderItem()).ToList());
            await _orderRepository.InsertAsync(order);

            return(order.Id);
        }
コード例 #2
0
        /// <summary>
        /// Handler which processes the command when
        /// customer executes cancel order from app
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public async Task <Unit> Handle(CreateOrderCommand command, CancellationToken cancellationToken)
        {
            var order = new Order(
                command.UserId,
                new Address(command.Street, command.City, command.State, command.Country, command.ZipCode),
                command.Description,
                command.OrderItems.Select(x => x.ToOrderItem()).ToList());
            await _orderRepository.InsertAsync(order);

            await _unitOfWorkManager.CommitAsync();

            return(Unit.Value);
        }
コード例 #3
0
        public async Task <IActionResult> TestCreate()
        {
            var order = new Order(
                "testUSer",
                new Address("Street", "City", "State", "Country", "ZipCode"),
                "Description",
                new List <OrderItem>
            {
                new OrderItem(Guid.NewGuid(),
                              "testProduct", 10, 0, "")
            });
            await _orderRepository.InsertAsync(order);

            // var order = await _orderRepository.GetAsync(Guid.Parse("35a00497-cbb0-4311-af5d-ab6b01281569"));
            // order.AddOrderItem(Guid.NewGuid(),
            //  "testProduct", 10, 0, "");
            // await _orderRepository.UpdateAsync(order);
            return(Ok(order));
        }