Ejemplo n.º 1
0
        public static BasketDto MapToBasketDto(Domain.Entities.BasketEntity basketEntityEntity)
        {
            // Transform BasketEntity to BasketDto
            var basketDto = new BasketDto();

            basketDto.BasketId  = basketEntityEntity.BasketId;
            basketDto.ItemCount = basketEntityEntity.Count;

            foreach (var item in basketEntityEntity.Items)
            {
                basketDto.CartItems.Add(new BasketItemDto
                {
                    ProductId = item.ProductId,
                    Name      = item.Title,
                    Artist    = item.Artist,
                    Genre     = item.Genre,
                    //ParentalCaution = item.ParentalCaution,
                    QuanityOrdered = item.Quantity,
                    Price          = TransformUnitPrice(item.UnitPrice, item.Quantity),
                }
                                        );

                basketDto.CartTotal = basketDto.CartItems.Sum(x => x.Price);
            }

            return(basketDto);
        }
Ejemplo n.º 2
0
        public static BasketSummaryDto MapToBasketSummaryDto(Domain.Entities.BasketEntity basketEntityEntity)
        {
            // Transform BasketEntity to BasketDto
            var basketSummaryDto = new BasketSummaryDto();

            basketSummaryDto.BasketId  = basketEntityEntity.BasketId;
            basketSummaryDto.ItemCount = basketEntityEntity.Items.Count;
            //basketSummaryDto.ProductNames = basketEntityEntity.Items.SelectMany(x => x.Title).ToString();
            basketSummaryDto.ProductNames = string.Join("\n", basketEntityEntity.Items.Select(c => c.Title).Distinct());

            return(basketSummaryDto);
        }