Exemple #1
0
        public ActionResult Index(DateTime date, int page)
        {
            ActionResult response = null;

            var errors = new List <string>();

            var eventsRepository = _dataRepositoryFactory.GetRepository <IEventsRepository>();

            var events = eventsRepository.GetAllWithComments(e => e.IsPublic && e.StartDate >= date, page, _pageSize);

            if (events == null)
            {
                errors.Add("Cannot evaluate this operation");
            }

            if (!errors.Any())
            {
                response = StatusCode((int)HttpStatusCode.OK, events);
            }
            else
            {
                response = StatusCode((int)HttpStatusCode.NotFound, errors);
            }

            return(response);
        }
Exemple #2
0
        public ActionResult Index(DateTime?date, int page = 0)
        {
            var eventsRepository = _dataRepositoryFactory.GetRepository <IEventsRepository>();

            var events = eventsRepository.GetAllWithComments(e => e.IsPublic && e.StartDate >= (date ?? new DateTime(1970, 01, 01)), page, _pageSize);

            var model = new IndexModel
            {
                Page   = page,
                Events = events
            };

            return(View(model));
        }