Example #1
0
        public IReadOnlyList <Event> GetValidEvent(int minimumGuests, bool validDate, bool premium)
        {
            //TODO : 03 - Filtro en DB con la specification
            var validEventSpecification = new ValidEventSpecification();

            using (var context = new EventsContext())
                return(context.Events.Where(validEventSpecification.ToExpression())
                       .ToList());
        }
Example #2
0
        public void CloseEventPremium(Event @event)
        {
            //TODO : 02 - Filtro en memoria con la specification
            var validEventSpecification = new ValidEventSpecification();

            if (validEventSpecification.IsSatisfiedBy(@event) && @event.Premium)
            {
                @event.Close();
                //_eventsRepository.Update(@event)
            }
        }
Example #3
0
        public IReadOnlyList <Event> GetValidPremium(int minimumGuests)
        {
            //TODO : 07 - Concateno specifications
            var minimumGuestsEventSpecification = new MinimumGuestsEventSpecification(minimumGuests);
            var validEventSpecification         = new ValidEventSpecification();
            var isPremiumEventSpecification     = new IsPremiumEventSpecification();

            using (var context = new EventsContext())
                return(context.Events.Where(minimumGuestsEventSpecification
                                            .And(validEventSpecification)
                                            .Or(isPremiumEventSpecification)
                                            .ToExpression())
                       .ToList());
        }