public ActionResult Index()
        {
            var currentPage = CurrentPage.DocumentTypeAlias;
            var umbContent  = UmbracoAssignedContentHelper.PageContentByAlias(currentPage);

            var xLargeImage = umbContent.GetCropUrl(propertyAlias: "responsiveImageExample", cropAlias: "X-Large-Desktop");
            var desktop     = umbContent.GetCropUrl(propertyAlias: "responsiveImageExample", cropAlias: "Desktop");
            var landScape   = umbContent.GetCropUrl(propertyAlias: "responsiveImageExample", cropAlias: "LandScape");
            var tablet      = umbContent.GetCropUrl(propertyAlias: "responsiveImageExample", cropAlias: "Tablet");
            var mobile      = umbContent.GetCropUrl(propertyAlias: "responsiveImageExample", cropAlias: "Mobile");

            var crops = umbContent.GetPropertyValue <ImageCropDataSet>("responsiveImageExample");

            int cropWidthXLarge    = crops.Crops.First(x => x.Alias.InvariantEquals("X-Large-Desktop")).Width;
            int cropWidthDesktop   = crops.Crops.First(x => x.Alias.InvariantEquals("DeskTop")).Width;
            int cropWidthLandScape = crops.Crops.First(x => x.Alias.InvariantEquals("LandScape")).Width;
            int cropWidthTablet    = crops.Crops.First(x => x.Alias.InvariantEquals("Tablet")).Width;
            int cropWidthMobile    = crops.Crops.First(x => x.Alias.InvariantEquals("Mobile")).Width;

            var model = new ResponsiveImageViewModel
            {
                XLargeImage        = xLargeImage,
                Desktop            = desktop,
                LandScape          = landScape,
                Tablet             = tablet,
                Mobile             = mobile,
                CropWidthXLarge    = $"{cropWidthXLarge}w",
                CropWidthDesktop   = $"{cropWidthDesktop}w",
                CropWidthLandscape = $"{cropWidthLandScape}w",
                CropWidthTablet    = $"{cropWidthTablet}w",
                CropWidthMobile    = $"{cropWidthMobile}w"
            };

            return(PartialView("~/Views/Partials/pvImageCropper.cshtml", model));
        }
        public static string SearchPageUrl()
        {
            var    umbContent    = UmbracoAssignedContentHelper.PageContentForIEnumerableIPublishedContent("homePage");
            string searchPageUrl = umbContent.First().GetPropertyValue <IPublishedContent>("searchPage").Url;

            return(searchPageUrl);
        }
        public ActionResult Index()
        {
            var currentPage = CurrentPage.DocumentTypeAlias;
            var umbContent  = UmbracoAssignedContentHelper.PageContentByAlias(currentPage);

            string textColour       = umbContent.GetPropertyValue <ColorPickerValueConverter.PickedColor>("textColour").Label;
            string backgroundColour = umbContent.GetPropertyValue <ColorPickerValueConverter.PickedColor>("sectionBackgroundColour").Label;
            int    fontSize         = umbContent.GetPropertyValue <int>("fontSize");

            string displayTextColour       = "black";
            string displayBackgroundColour = "white";

            switch (textColour)
            {
            case nameof(EnumColourPicker.ColourPickerEnum.Red):
                displayTextColour = "textRed";
                break;

            case nameof(EnumColourPicker.ColourPickerEnum.Black):
                displayTextColour = "textBlack";
                break;
            }

            switch (Regex.Replace(backgroundColour, " ", ""))
            {
            case nameof(EnumColourPicker.ColourPickerEnum.Tomato):
                displayBackgroundColour = "backgroundColourTomato";
                break;

            case nameof(EnumColourPicker.ColourPickerEnum.DarkOrange):
                displayBackgroundColour = "backgroundColourDarkOrange";
                break;
            }

            string displayfontSize = DisplayFontSize.SectionFontSize(fontSize);

            var model = new ColourPickerViewModel
            {
                TextColour       = displayTextColour,
                BackgroundColour = displayBackgroundColour,
                FontSize         = displayfontSize
            };

            return(PartialView("~/Views/Partials/pvEnumColourExample.cshtml", model));
        }
Exemplo n.º 4
0
        public JsonResult GetCurrentBookings()
        {
            List <IPublishedContent> bookingDetails = UmbracoAssignedContentHelper.PageContentForIEnumerableIPublishedContent("bookings").DescendantsOrSelf("year").Where(x => x.GetPropertyValue <bool>("archiveYear") == false).SelectMany(x => x.Children).Where(x => x.GetPropertyValue <bool>("bookingConfirmed")).ToList();

            List <string> bookingModel = new List <string>();

            foreach (var booking in bookingDetails)
            {
                var bookingDatesArrive = booking.GetPropertyValue <DateTime>("startDate");
                var bookingDatesDepart = booking.GetPropertyValue <DateTime>("endDate");

                for (var dt = bookingDatesArrive; dt <= bookingDatesDepart; dt = dt.AddDays(1))
                {
                    bookingModel.Add(dt.ToString("yyyy-MM-dd"));
                }
            }
            return(Json(new { BookingArray = bookingModel.ToArray() }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public ActionResult Index()
        {
            var    currentPage             = CurrentPage.DocumentTypeAlias;
            var    umbContent              = UmbracoAssignedContentHelper.PageContentByAlias(currentPage);
            string displayImage            = string.Empty;
            string doesImageMediaHaveValue = umbContent.GetPropertyValue <string>("testMediaImage", "NA");

            if (int.TryParse(doesImageMediaHaveValue, out _))
            {
                displayImage = umbContent.GetPropertyValue <IPublishedContent>("testMediaImage").Url;
            }

            var model = new CheckForNullViewModel
            {
                TestString = umbContent.GetPropertyValue <string>("testString", "I have no value"),
                TestRte    = umbContent.GetPropertyValue("testRte", new HtmlString("RTE has no value")),
                TestImage  = displayImage
            };

            return(PartialView("~/Views/Partials/pvCheckForNulls.cshtml", model));
        }