예제 #1
0
        public LocationsModel(
            IPublishedContent content,
            IPublishedContent recommendationRepository,
            bool isEnglish,
            int?tagId,
            string tag,
            IContentService contentService) :
            base(content)
        {
            UmbracoHelper helper = new UmbracoHelper(UmbracoContext.Current, content);

            this.Tags = helper.TagQuery.GetAllTags(Constants.NodeAlias.TAG_GROUP);

            if (tagId.HasValue)
            {
                tag = this.Tags.First(x => x.Id == tagId.Value).Text;
            }
            else
            {
                tag = Constants.NodeAlias.DEFAULT_TAG;
            }


            this.Locations = new List <LocationModel>();

            var locations = helper.TagQuery.GetContentByTag(tag, Constants.NodeAlias.TAG_GROUP);

            this.Locations
            .AddRange(locations.Where(x => x.GetPropertyValue <bool>(Constants.Location.Properties.PUBLISHED))
                      .Select(x => LocationFactory.Create(x, recommendationRepository, contentService, isEnglish, isDetails: false)));
        }
예제 #2
0
        public RecommendationModel(
            IPublishedContent content,
            IPublishedContent recommendationRepository,
            IContentService contentService,
            bool isEnglish,
            bool isDetails) : base(
                content,
                Thread.CurrentThread.CurrentUICulture)
        {
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }

            this.IsDetails        = isDetails;
            this.IsEnglish        = isEnglish;
            this.HeadLine         = content.GetPropertyValue <string>(HeadLineProperty);
            this.SubHeader        = content.GetPropertyValue <string>(SubHeaderProperty);
            this.Body             = content.GetPropertyValue <string>(BodyProperty);
            this.Id               = content.Id;
            this.IsGuestWriter    = content.GetPropertyValue <bool>(Constants.Recommendation.Properties.GUEST_WRITER);
            this.WriterName       = content.GetPropertyValue <string>(Constants.Recommendation.Properties.GUEST_WRITER_NAME);
            this.WriterUrl        = content.GetPropertyValue <string>(Constants.Recommendation.Properties.GUEST_WRITER_LINK);
            this.Organizer        = content.GetPropertyValue <string>(Constants.Recommendation.Properties.ORGANIZER);
            this.StartDate        = content.GetPropertyValue <DateTime>(Constants.Recommendation.Properties.START_DATE);
            this.EndDate          = content.GetPropertyValue <DateTime>(Constants.Recommendation.Properties.END_DATE);
            this.Price            = content.GetPropertyValue <decimal>(Constants.Recommendation.Properties.PRICE);
            this.StartTime        = content.GetPropertyValue <DateTime>(Constants.Recommendation.Properties.START_TIME);
            this.EndTime          = content.GetPropertyValue <DateTime?>(Constants.Recommendation.Properties.END_TIME);
            this.DoorOpens        = content.GetPropertyValue <DateTime?>(Constants.Recommendation.Properties.DOOR_OPENS);
            this.EventType        = content.GetPropertyValue <string>(Constants.Recommendation.Properties.EVENT_TYPE);
            this.LinkToEvent      = content.GetPropertyValue <string>(Constants.Recommendation.Properties.LINK_TO_EVENT);
            this.ImageUrl         = content.GetCropUrl(Constants.Recommendation.Properties.IMAGE_URL, Constants.Crop.RECOMMENDATION_IMAGE);
            this.FacebookImageUrl = content.GetCropUrl(Constants.Recommendation.Properties.IMAGE_URL, Constants.Crop.FACEBOOK_IMAGE);
            this.TicketUrl        = content.GetPropertyValue <string>(Constants.Recommendation.Properties.TICKET_URL);
            this.OldId            = content.GetPropertyValue <int>(Constants.Recommendation.Properties.OLD_ID);

            if (this.IsGuestWriter == false)
            {
                int writerId = content.GetPropertyValue <int>(Constants.Recommendation.Properties.WRITER);
                this.WriterId = writerId;
                IPublishedContent writer = this.Helper.TypedContent(writerId);

                if (writer != null)
                {
                    this.WriterName       = writer.Name;
                    this.WriterImage      = writer.GetCropUrl(Constants.Writer.Properties.IMAGE, Constants.Crop.MINITURE_CROP);
                    this.WriterBackground = writer.GetPropertyValue <string>(Constants.Writer.Properties.BACKGROUND);
                }
            }

            int translatorId = content.GetPropertyValue <int>(Constants.Recommendation.Properties.TRANSLATOR);

            this.TranslatorId = translatorId;
            IPublishedContent translator = this.Helper.TypedContent(translatorId);

            if (translator != null)
            {
                this.TranslatorName = translator.Name;
            }

            int locationId = content.GetPropertyValue <int>(Constants.Recommendation.Properties.LOCATION);

            IPublishedContent location = this.Helper.TypedContent(locationId);

            if (location != null)
            {
                this.Location = LocationFactory.Create(location, recommendationRepository, contentService, isEnglish, isDetails: false);
            }
        }