Example #1
0
        public void UpdateSiteStyle(SiteStyleSheet updated, string pagename, bool singlePage, HttpPostedFileBase thisFile, int headerSize, int headerAlign)
        {
            if (updated != null)
            {
                using (this.ef = new CMSDbEntities())
                {
                    var original = this.ef.SiteStyleSheets.Find(this.ef.PageSettings.Find(this.ThisPageId).SiteStyleSheet.Id);

                    original.color_header_background = updated.color_header_background;
                    original.color_header_text       = updated.color_header_text;
                    original.color_header_title      = updated.color_header_title;
                    original.color_site_background   = updated.color_site_background;
                    original.font_family_header      = updated.font_family_header;
                    original.font_family_header_menu = updated.font_family_header_menu;

                    var originalsetting = this.ef.PageSettings.Find(this.ThisPageId);
                    originalsetting.PageName         = pagename;
                    originalsetting.singlePage       = singlePage;
                    originalsetting.HeaderSize       = headerSize;
                    originalsetting.AlignHeaderRight = headerAlign;

                    if (thisFile != null && thisFile.ContentLength > 100)
                    {
                        var lenght    = thisFile.ContentLength;
                        var tempimage = new byte[lenght];
                        thisFile.InputStream.Read(tempimage, 0, lenght);

                        var wi     = new WebImage(tempimage);
                        var height = wi.Height;
                        if (wi.Height > 60)
                        {
lel:
                            var ratio = (double)60 / (double)height;

                            if (ratio != 0)
                            {
                                wi.Resize(Convert.ToInt32(wi.Width * ratio), 60);
                                originalsetting.HeaderImage     = wi.GetBytes();
                                originalsetting.HeaderImageType = thisFile.ContentType;
                            }
                            else
                            {
                                goto lel;
                            }
                        }
                        else
                        {
                            originalsetting.HeaderImage     = tempimage;
                            originalsetting.HeaderImageType = thisFile.ContentType;
                        }
                    }

                    this.ef.SaveChanges();
                }
            }
        }
Example #2
0
        public ActionResult EditSiteStyle(FormCollection collection)
        {
            if (System.Web.HttpContext.Current.Session["admin"] != null && System.Web.HttpContext.Current.Session["admin"].ToString() == "iamadmin" && collection != null)
            {
                switch (collection["submit"])
                {
                case "Save":
                    var colorHeaderText       = collection["menuTextColor"];
                    var colorHeaderTitle      = collection["titleTextColor"];
                    var colorHeaderBackground = collection["menuColor"];
                    var colorSiteBackground   = collection["backgroundColor"];
                    var fontHeaderTitle       = collection["titleFont"];
                    var fontHeaderMenu        = collection["menuFont"];
                    var pageName   = collection["pageName"];
                    var imagefile  = this.Request.Files["imagefile"];
                    var singlePage = Convert.ToBoolean(collection["singlePage"], CultureInfo.CurrentCulture);
                    var headerSize = Convert.ToInt32(collection["headerSize"], CultureInfo.CurrentCulture);

                    var headerPlacement = Convert.ToInt32(collection["AlignLogoRight"], CultureInfo.CurrentCulture);

                    var sss = new SiteStyleSheet()
                    {
                        color_header_background = colorHeaderBackground,
                        color_header_text       = colorHeaderText,
                        color_header_title      = colorHeaderTitle,
                        color_site_background   = colorSiteBackground,
                        font_family_header      = fontHeaderTitle,
                        font_family_header_menu = fontHeaderMenu
                    };

                    this.rc.Style.UpdateSiteStyle(sss, pageName, singlePage, imagefile, headerSize, headerPlacement);

                    this.rc.ClearPanelCache();
                    this.rc.ClearStyleCache();
                    return(this.RedirectToAction("EditSiteStyle", "Edit"));

                case "Cancel":
                    return(this.RedirectToAction("AdminHome", "Admin"));

                case "deleteLogo":
                    this.rc.Style.RemoveHeaderLogo();

                    this.rc.ClearPanelCache();
                    return(this.RedirectToAction("EditSiteStyle", "Edit"));

                default:
                    throw new ArgumentNullException("collection");
                }
            }
            else
            {
                return(this.RedirectToAction("AdminLogOn", "Admin"));
            }
        }