public string GetHtml(Dictionary <string, string> parameters)
        {
            ClassName = parameters != null && parameters.ContainsKey("class") ? parameters["class"] : "responsive-image";

            if (parameters != null && parameters.ContainsKey("src") && !String.IsNullOrEmpty(parameters["src"]))
            {
                ImagePath = parameters["src"];
            }

            if (parameters != null && parameters.ContainsKey("alt") && !String.IsNullOrEmpty(parameters["alt"]))
            {
                AltText = parameters["alt"];
            }

            if (parameters != null && parameters.ContainsKey("width") && !String.IsNullOrEmpty(parameters["width"]))
            {
                Width = Convert.ToInt16(parameters["width"]);
            }

            if (parameters != null && parameters.ContainsKey("height") && !String.IsNullOrEmpty(parameters["height"]))
            {
                Height = Convert.ToInt16(parameters["height"]);
            }

            return(DynamicModules.GetViewHtml("Partials/_ResponsiveImagePartial", this));
        }
예제 #2
0
        public string GetHtml(Dictionary <string, string> parameters)
        {
            var model = new ResponsiveImageUtils.ResponsiveImageObject
            {
                ClassName = parameters != null && parameters.ContainsKey("class") ? parameters["class"] : "responsive-image",
                Sizes     = ResponsiveImageUtils.ResponsiveImageSizes,
                ImagePath = "",
                AltText   = "",
                Width     = 0,
                Height    = 0
            };

            if (parameters != null && parameters.ContainsKey("sizes") && !String.IsNullOrEmpty(parameters["sizes"]))
            {
                model.Sizes = parameters["sizes"];
            }

            if (parameters != null && parameters.ContainsKey("src") && !String.IsNullOrEmpty(parameters["src"]))
            {
                model.ImagePath = parameters["src"];
            }

            if (parameters != null && parameters.ContainsKey("alt") && !String.IsNullOrEmpty(parameters["alt"]))
            {
                model.AltText = parameters["alt"];
            }

            if (parameters != null && parameters.ContainsKey("width") && !String.IsNullOrEmpty(parameters["width"]))
            {
                model.Width = Convert.ToInt16(parameters["width"]);
            }

            if (parameters != null && parameters.ContainsKey("height") && !String.IsNullOrEmpty(parameters["height"]))
            {
                model.Height = Convert.ToInt16(parameters["height"]);
            }

            return(DynamicModules.GetViewHtml("Partials/_ResponsiveImagePartial", model));
        }
예제 #3
0
        public string GetHtml(Dictionary <string, string> parameters)
        {
            TheEvents   = new List <Event>();
            ShowHeading = (parameters != null && parameters.ContainsKey("showHeading") ? parameters["showHeading"] != "false" : true);
            var events = new List <string>();

            using (var context = new DataContext())
            {
                // event name(s) are supplied, only select by names
                if (parameters != null && parameters.ContainsKey("name"))
                {
                    if (parameters["name"].Contains(" "))
                    {
                        events.AddRange(parameters["name"].ToLower().Split(' ').ToList());
                    }
                    else
                    {
                        events.Add(parameters["name"].ToLower().Replace(" ", ""));
                    }

                    TheEvents =
                        context.Events.Where(x => x.IsActive && events.Contains(x.Title.Replace(" ", "").ToLower())).ToList();
                }
                else if (parameters != null && parameters.ContainsKey("id"))
                {
                    var eventId = Convert.ToInt16(parameters["id"]);
                    TheEvents = context.Events.Where(x => x.IsActive && x.EventId == eventId).ToList();
                }
                else
                {
                    var count = (parameters != null && parameters.ContainsKey("count") ? Int32.Parse(parameters["count"]) : 4);

                    var query = "SELECT * FROM dbo.Events WHERE Events.IsActive = 1";
                    if (parameters != null && parameters.ContainsKey("featured"))
                    {
                        query += " AND Events.IsFeatured = " + parameters["featured"].ToLower() == "true" ? "1" : "0";
                    }
                    // categories have been supplied, could be multiples
                    if (parameters != null && parameters.ContainsKey("category"))
                    {
                        if (parameters["category"].Contains(" "))
                        {
                            events.AddRange(parameters["category"].ToLower().Split(' ').ToList());
                        }
                        else
                        {
                            events.Add(parameters["category"].ToLower().Replace(" ", ""));
                        }
                        query += " AND " + string.Format("(Events.MainCategory IS NOT NULL AND LOWER(REPLACE(Events.MainCategory, N' ', N'')) IN ({0}))", String.Join(",", events.Select(x => "'" + x + "'")));
                    }
                    var startDate = (parameters != null && parameters.ContainsKey("startDate") ? DateTime.Parse(parameters["startDate"]) : DateTime.UtcNow.Date);
                    var endDate   = (parameters != null && parameters.ContainsKey("endDate") ? DateTime.Parse(parameters["endDate"]) : DateTime.MaxValue);
                    query += " AND " + string.Format("(Events.StartDate IS NULL OR Events.StartDate <= '{0}') AND (Events.EndDate IS NULL OR Events.EndDate >= '{1}')", endDate, startDate);
                    query += " ORDER BY Events.StartDate";

                    TheEvents = context.Database.SqlQuery <Event>(query).Take(count).ToList();
                }

                return(TheEvents.Any() ? DynamicModules.GetViewHtml("Partials/FeaturedEventsShortcodePartial", this) : String.Empty);
            }
        }
예제 #4
0
 public static String GetTimeConvertedDynamicHtml(string partialViewName, object model)
 {
     ConvertAllMembersToLocal(model);
     return(DynamicModules.GetViewHtml(partialViewName, model));
 }