Exemplo n.º 1
0
        public IActionResult GetPrice([FromBody] OrderDTO data)
        {
            var shapeIds = data.OrderLines.Select(ol => ol.ShapeId).ToList();
            var shapes   = Db.Shape.Where(s => shapeIds.Contains(s.Id.ToString())).Select(s => new Shape {
                Id = s.Id, Width = s.Width, Height = s.Height
            }).ToList();

            data.Price = PriceCalculator.CalculateOrderPrice(data, shapes);
            return(Json(data));
        }
        public void CalculateOrderPrice_ValidValues_ShouldWork(OrderDTO order, List <Shape> shapes, decimal expected)
        {
            decimal actual = PriceCalculator.CalculateOrderPrice(order, shapes);

            Assert.Equal(expected, actual);
        }