public static Basket Convert(CreateBasketDTO dto) { if (dto == null) { throw new ArgumentNullException(nameof(dto)); } return(new Basket { User = UserConverter.Convert(dto.User), UserId = dto.User.Id }); }
public static Basket Convert(BasketDTO basket) { if (basket == null) { throw new ArgumentNullException(nameof(basket)); } return(new Basket { Id = basket.Id, UserId = basket.User.Id, BasketItems = BasketItemsConverter.Convert(basket.BasketItems), User = UserConverter.Convert(basket.User) }); }
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() }); }
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() }); }
public static BasketDTO Convert(Basket basket) { if (basket == null) { throw new ArgumentNullException(nameof(basket)); } var dto = new BasketDTO { Id = basket.Id, User = UserConverter.Convert(basket.User) }; if (basket.BasketItems != null) { dto.BasketItems = BasketItemsConverter.Convert(basket.BasketItems); } return(dto); }