Beispiel #1
0
        public static OrderDTO Convert(BasketDTO basketDTO)
        {
            if (basketDTO == null)
            {
                throw new ArgumentNullException(nameof(basketDTO));
            }

            return(new OrderDTO
            {
                //TotalPrice = basketDTO.BasketItems.Select(p => p.Product.Price).Sum(),
                User = basketDTO.User,
                OrderItems = OrderItemsConverter.Convert(basketDTO.BasketItems)
            });
        }
Beispiel #2
0
        public static OrderDTO Convert(Order order)
        {
            if (order == null)
            {
                throw new ArgumentNullException(nameof(order));
            }

            return(new OrderDTO
            {
                Id = order.Id,
                Comment = order.Comment,
                User = UserConverter.Convert(order.User),
                OrderItems = OrderItemsConverter.Convert(order.OrderItems),
                TotalPrice = order.OrderItems.Select(p => p.Product.Price).Sum()
            });
        }
Beispiel #3
0
        public static Order Convert(CreateOrderDTO dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException(nameof(dto));
            }

            return(new Order
            {
                Comment = dto.Comment,
                User = UserConverter.Convert(dto.User),
                UserId = dto.User.Id,
                OrderItems = OrderItemsConverter.Convert(dto.OrderItems),
                TotalPrice = dto.OrderItems.Select(p => p.Product.Price).Sum()
            });
        }