示例#1
0
 public static OrderDTO OrderToOrderDTO(Order input, List <Product> products)
 {
     return(new OrderDTO()
     {
         Id = input.OrderId,
         Person = PersonMapper.PersonToPersonDTO(input.Person),
         CustomerMail = input.Person.Email,
         Products = DBProductMapper.ProductsToListOfProductDTOs(products),
         TotalPrice = Convert.ToDouble(input.TotalPrice)
     });
 }
示例#2
0
        public static OrderDTO OrderToOrderDTOV2(Order input, List <OrderProduct> orderProducts, List <Product> products)
        {
            OrderDTO dto = new OrderDTO();

            dto.Id           = input.OrderId;
            dto.Person       = PersonMapper.PersonToPersonDTO(input.Person);
            dto.CustomerMail = dto.Person.Email;
            dto.TotalPrice   = Convert.ToInt32(input.TotalPrice);
            dto.OrderNumber  = input.OrderId;
            dto.Products     = DBProductMapper.ProductsToListOfProductDTOs(products);
            foreach (var product in dto.Products)
            {
                product.Amount = orderProducts.Where(x => x.ProductId == product.Id && x.OrderId == input.OrderId).Select(x => x.Amount).Single();
            }
            return(dto);
        }