Ejemplo n.º 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 = Order.Create(
            command.UserId,
            new Address(command.Street, command.City, command.State, command.Country, command.ZipCode),
            command.Description
            );

        // await _orderRepository.LoadAsync(order, x => x.Items);

        foreach (var item in command.OrderItems)
        {
            order.AddItem(item.ProductId, item.ProductName, item.UnitPrice, item.Discount,
                          item.PictureUrl, item.Units);
        }

        await _orderRepository.AddAsync(order);

        return(order.Id);
    }
Ejemplo n.º 2
0
    public async Task <IActionResult> TestCreate()
    {
        var order = Order.Create(
            "testUSer",
            new Address("Street", "City", "State", "Country", "ZipCode"),
            "Description");

        order.AddItem(Guid.NewGuid(),
                      "testProduct1", 10, 0, "");
        order.AddItem(Guid.NewGuid(),
                      "testProduct2", 10, 0, "");
        order.SetRivalNetwork(new[] { "hi1", "hi2" });
        order.AddKeyValue("test1", "value1");
        order.AddKeyValue("test2", "value2");
        order.AddExtra("n1", "a1");
        order.AddExtra("n2", "a2");
        await _orderRepository.AddAsync(order);

        return(Ok(order));
    }
Ejemplo n.º 3
0
 public async Task <Orders> AddOrder(Orders order)
 {
     return(await _orderRpo.AddAsync(order));
 }