public ActionResult EventPageSearchAutoComplete(string term)
        {
            if (String.IsNullOrWhiteSpace(term) || term.Length < _mobSocialSettings.EventPageSearchTermMinimumLength)
            {
                return(Json(new object()));
            }

            var items = _eventPageService.GetAll(term, _mobSocialSettings.EventPageSearchAutoCompleteNumberOfResults);


            var models = new List <object>();

            foreach (var item in items)
            {
                var entityPicture  = _eventPageService.GetFirstEntityPicture(item.Id);
                var defaultPicture = (entityPicture != null) ? _pictureService.GetPictureById(entityPicture.PictureId) : null;

                models.Add(new
                {
                    DisplayName = item.Name,
                    Url         = Url.RouteUrl("EventPageUrl", new { SeName = item.GetSeName() }),
                    PictureUrl  = _pictureService.GetPictureUrl(defaultPicture, 50, true),
                    //TODO: Add EventStartsFormat as locale resource string
                    EventStartsText = "Starts " + item.StartDate.ToString("MMMM d, yyyy") + " at " + item.StartDate.ToString("hh:mmtt"),
                });
            }

            return(Json(models, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public ActionResult GetAll(DataSourceRequest command)
        {
            var entities = _eventPageService.GetAll();

            var models = new List <object>();

            foreach (var entity in entities)
            {
                var entityPicture  = _eventPageService.GetFirstEntityPicture(entity.Id);
                var defaultPicture = (entityPicture != null) ? _pictureService.GetPictureById(entityPicture.PictureId) : null;

                var model = new {
                    Id = entity.Id,
                    PictureThumbnailUrl = _pictureService.GetPictureUrl(defaultPicture, 75, true),
                    Name    = entity.Name,
                    Address = entity.LocationName + " " + entity.LocationAddress1 + " " + entity.LocationAddress2 + " " +
                              entity.LocationCity + ", " + entity.LocationState + " " +
                              entity.LocationZipPostalCode + " " + entity.LocationCountry,
                    LocationContactInfo = entity.LocationPhone + " " + entity.LocationEmail + " " + entity.LocationWebsite,
                    StartDate           = entity.StartDate,
                    EndDate             = entity.EndDate,
                    DateCreated         = entity.DateCreated.ToString(),
                    DateUpdated         = entity.DateUpdated.ToString(),
                };

                models.Add(model);
            }


            var gridModel = new DataSourceResult
            {
                Data  = models,
                Total = entities.Count()
            };

            return(Json(gridModel));
        }