Exemplo n.º 1
0
        public List <CustomerTestimonialAggregate> GetAcceptedTestimonials(bool?isAccepted, string gender, int pageNumber, int pageSize)
        {
            List <Testimonial> testimonials;
            var customerTestimonialAggregates = new List <CustomerTestimonialAggregate>();

            try
            {
                testimonials = _testimonialRepository.GetAcceptedTestimonials(isAccepted, gender, pageNumber, pageSize);
            }
            catch (Exception)
            {
                return(null);
            }
            var testimonialGroups = testimonials.GroupBy(t => t.CustomerId);
            ICustomerTestimonialAggregateFactory customerTestimonialAggregateFactory =
                new CutomerTestimonailAggregateFactory();

            foreach (var testimonialGroup in testimonialGroups)
            {
                customerTestimonialAggregates.Add(customerTestimonialAggregateFactory.CreateCustomerTestimonialAggregate(testimonialGroup));
            }
            return(customerTestimonialAggregates);
        }