Ejemplo n.º 1
0
        public ActionResult EventsBox(string eventDate, string eventTypeUrl)
        {
            var      format  = new CultureInfo("uk-UA");
            DateTime publish = eventDate == null ? DateTime.MinValue : DateTime.Parse(eventDate.Replace("_", "."), format);

            //var today = DateTime.Now;

            //if (publish == new DateTime(today.Year, today.Month, today.Day))
            //{
            //    publish = DateTime.MinValue;
            //}
            var model = Mapper.Map <List <EventBaseVm> >(_context.GetEventsByFiltersStoredPr(publish, eventTypeUrl));

            var places = _context.GetPlaceInfo(model.Select(s => s.EventId).ToList());

            Parallel.ForEach(model, eventItem =>
            {
                if (places.ContainsKey(eventItem.EventId))
                {
                    eventItem.PlaceUrl  = places[eventItem.EventId].Item1;
                    eventItem.PlaceName = places[eventItem.EventId].Item2;
                }
            });

            return(PartialView("_EventsBox", model));
        }