Ejemplo n.º 1
0
        public void Resovle_WhenListEmpty()
        {
            //arrange
            var stockOrderCreate = new StockOrderCreate();

            //act
            StockOrderCreateCalculateTotalCostInPounds.Resolve(stockOrderCreate);
            //assert
            Assert.Equal(0, stockOrderCreate.TotalPrice);
        }
        public static void Resolve(StockOrderCreate stockOrderCreate)
        {
            decimal result = 0;

            foreach (var item in stockOrderCreate.OrderItems)
            {
                result += item.TotalCostInPounds;
            }

            stockOrderCreate.TotalPrice = result;
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> HandleAsync(StockOrderCreate stockOrderCreate)
        {
            var result = await _orderItemManager.OrderCreate(stockOrderCreate);

            if (result.Success)
            {
                return(Ok(result));
            }
            else
            {
                return(BadRequest(result));
            }
        }
Ejemplo n.º 4
0
        public void Resolve(decimal totalCostInPounds, decimal expected)
        {
            //arrange
            var stockOrderCreate = new StockOrderCreate();

            stockOrderCreate.OrderItems.Add(new OrderItemsCreate()
            {
                TotalCostInPounds = 1
            });
            stockOrderCreate.OrderItems.Add(new OrderItemsCreate()
            {
                TotalCostInPounds = totalCostInPounds
            });
            //act
            StockOrderCreateCalculateTotalCostInPounds.Resolve(stockOrderCreate);
            //assert
            Assert.Equal(expected, stockOrderCreate.TotalPrice);
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> Post(StockOrderCreate stockOrderCreate)
        {
            stockOrderCreate.OrderItems.Add(new OrderItemsCreate()
            {
                Name = "a1", Quantity = 100
            });

            var result = await _orderItemManager.OrderCreate(stockOrderCreate);

            if (result.Success)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest(result.Message));
            }
        }
Ejemplo n.º 6
0
 public async Task <StockOrderOrderResponse> OrderCreate(StockOrderCreate stockOrderCreate)
 {
     return(_mapper.Map <StockOrderOrderResponse>(await _orderItemService.OrderCreate(_mapper.Map <StockOrder>(stockOrderCreate))));
 }
Ejemplo n.º 7
0
 protected override void OnInitialized()
 {
     StockOrder = new StockOrderCreate();
 }