Ejemplo n.º 1
0
        public ActionResult StaticRender(string slug, int?pid)
        {
            if (Convert.ToBoolean(Request.QueryString["init"]))
            {
                SiteCacher.ClearCache(Site.ID);
            }

            if (slug.Equals("shoppingcart"))
            {
                return(RedirectToRoute("shoppingcart_us", new { area = "" }));
            }

            if (slug.EndsWith("/"))
            {
                slug = slug + "index"; //landing page
            }
            //filter Page
            using (CurrentSiteSettings settings = new CurrentSiteSettings(SiteCacher.CurrentSite))
            {
                ViewBag.UserName           = User.Identity.IsAuthenticated ? loginuser.Details.FirstName + " " + loginuser.Details.LastName : "";
                _viewModel.CurrentUserName = ViewBag.UserName;

                return(FilterPage(slug, settings, pid));
            }
        }
Ejemplo n.º 2
0
        public ActionResult index(string slug = "")
        {
            var currentsite = SiteCacher.CurrentSite;

            if (Convert.ToBoolean(Request.QueryString["init"]))
            {
                SiteCacher.ClearCache(Site.ID);
            }


            _viewModel.CMSPage = _service.GetPageMetadata(Site.ID, WBHelper.CurrentLangID(), "/index");
            ReplaceMetaTag();


            int UserID = 0;

            if (User.Identity.IsAuthenticated)
            {
                _viewModel.CurrentUserName = loginuser.Details.FirstName + " " + loginuser.Details.LastName;
                if (loginuser != null && loginuser.Details != null)
                {
                    UserID = loginuser.Details.ID;
                }
                else if (User.Identity.IsAuthenticated && !string.IsNullOrEmpty(User.Identity.Name))
                {
                    if (loginuser != null && loginuser.Details != null)
                    {
                        UserID = loginuser.Details.ID;
                    }
                }
            }

            if (ContractID.Equals(0))
            {
                ContractID = WBHelper.GetCurrentContractID(UserID, Site.ID);
            }

            _viewModel.Items = _service.GetAllProductPricing(currentsite.ID, ContractID);
            return(View(_viewModel));
        }
        public ActionResult SaveBanner()
        {
            string strFilePath = Request.PhysicalApplicationPath + "\\Upload\\" + Site.ID + "\\Temp";
            string FileName    = "banner-" + Site.ID + System.IO.Path.GetExtension(Request.Files["fupBanner"].FileName);

            if (Directory.Exists(strFilePath))
            {
                Directory.Delete(strFilePath, true);
            }
            Directory.CreateDirectory(strFilePath);
            if (System.IO.File.Exists(strFilePath + "\\" + FileName))
            {
                System.IO.File.Delete(strFilePath + "\\" + FileName);
            }
            Request.Files["fupBanner"].SaveAs(strFilePath + "\\" + FileName);
            int Width = 0, Height = 0;

            GetImageWidthAndHeight(strFilePath + "\\" + FileName, ref Width, ref Height);
            bool NeedToCrop = false;

            if (Width > Convert.ToInt32(System.Web.Configuration.WebConfigurationManager.AppSettings["BannerWidth"]) || Height > Convert.ToInt32(System.Web.Configuration.WebConfigurationManager.AppSettings["BannerHeight"]))
            {
                NeedToCrop = true;
            }
            else
            {
                if (System.IO.File.Exists(Request.PhysicalApplicationPath + "\\Upload\\" + Site.ID + "\\" + FileName))
                {
                    System.IO.File.Delete(Request.PhysicalApplicationPath + "\\Upload\\" + Site.ID + "\\" + FileName);
                }
                System.IO.File.Move(strFilePath + "\\" + FileName, Request.PhysicalApplicationPath + "\\Upload\\" + Site.ID + "\\" + FileName);
                var _Settings = DependencyResolver.Current.GetService <IRepository <SiteSettings> >();
                var _item     = _Settings.Find(ss => ss.SiteID == Site.ID && ss.Key.ToLower().Equals(SettingConstants.CURRENT_BANNERFILE_KEY)).FirstOrDefault();
                if (_item != null)
                {
                    _item.Site = null;
                }
                else
                {
                    _item = new SiteSettings();
                }
                _item.Key    = SettingConstants.CURRENT_BANNERFILE_KEY;
                _item.Value  = FileName;
                _item.SiteID = Site.ID;
                if (_item.ID > 0)
                {
                    _Settings.Update(_item);
                }
                else
                {
                    _Settings.Add(_item);
                }

                var _item2 = _Settings.Find(ss => ss.SiteID == Site.ID && ss.Key.ToLower().Equals(SettingConstants.CURRENT_NEEDBANNER_KEY)).FirstOrDefault();
                if (_item2 != null)
                {
                    _item2.Site = null;
                }
                else
                {
                    _item2 = new SiteSettings();
                }
                _item2.Key    = SettingConstants.CURRENT_NEEDBANNER_KEY;
                _item2.Value  = "True";
                _item2.SiteID = Site.ID;
                if (_item2.ID > 0)
                {
                    _Settings.Update(_item2);
                }
                else
                {
                    _Settings.Add(_item2);
                }

                _unitOfWork.Commit();
                SiteCacher.ClearCache(Site.ID);
            }
            FileUploadResponse objResp = new FileUploadResponse();

            objResp.FilePath     = "/upload/" + Site.ID + "/" + FileName;
            objResp.NeedToCrop   = NeedToCrop;
            objResp.PhysicalPath = strFilePath + "\\" + FileName;
            objResp.Type         = "banner";
            return(Json(objResp));
        }
        public ActionResult SaveLogo()
        {
            FileUploadResponse objResp = null;

            try
            {
                if (Request.Files["fupBanner"] != null && Request.Files["fupBanner"].ContentLength > 0)
                {
                    return(SaveBanner());
                }
                else
                {
                    //string strFilePath = Request.PhysicalApplicationPath + "\\Upload\\" + Site.ID + "\\Temp";
                    string strFilePath = Request.PhysicalApplicationPath + "\\Upload\\sitelogo\\Temp";
                    //string FileName = "logo" + Site.ID + System.IO.Path.GetExtension(Request.Files["fupLogo"].FileName);
                    string FileName = "logo" + System.IO.Path.GetExtension(Request.Files["fupLogo"].FileName);
                    if (Directory.Exists(strFilePath))
                    {
                        Directory.Delete(strFilePath, true);
                    }
                    Directory.CreateDirectory(strFilePath);

                    if (System.IO.File.Exists(strFilePath + "\\" + FileName))
                    {
                        System.IO.File.Delete(strFilePath + "\\" + FileName);
                    }
                    Request.Files["fupLogo"].SaveAs(strFilePath + "\\" + FileName);
                    int Width = 0, Height = 0;
                    GetImageWidthAndHeight(strFilePath + "\\" + FileName, ref Width, ref Height);
                    bool NeedToCrop = false;
                    if (Width > Convert.ToInt32(System.Web.Configuration.WebConfigurationManager.AppSettings["LogoWidth"]) || Height > Convert.ToInt32(System.Web.Configuration.WebConfigurationManager.AppSettings["LogoHeight"]))
                    {
                        NeedToCrop = true;
                    }
                    else
                    {
                        try
                        {
                            if (System.IO.File.Exists(Request.PhysicalApplicationPath + "\\Upload\\sitelogo\\" + FileName))
                            {
                                System.IO.File.Delete(Request.PhysicalApplicationPath + "\\Upload\\sitelogo\\" + FileName);
                            }
                            System.IO.File.Move(strFilePath + "\\" + FileName, Request.PhysicalApplicationPath + "\\Upload\\sitelogo\\" + FileName);
                        }
                        catch (Exception ex)
                        {
                            _logger.LogException(ex);
                        }


                        var _Settings = DependencyResolver.Current.GetService <IRepository <SiteSettings> >();
                        var _item     = _Settings.Find(ss => ss.SiteID == Site.ID && ss.Key.ToLower().Equals(SettingConstants.CURRENT_SITELOGO_KEY)).FirstOrDefault();
                        if (_item == null)
                        {
                            _item = new SiteSettings();
                        }


                        _item.Key    = SettingConstants.CURRENT_SITELOGO_KEY;
                        _item.Value  = FileName;
                        _item.SiteID = Site.ID;
                        if (_item.ID > 0)
                        {
                            _Settings.Update(_item);
                        }
                        else
                        {
                            _Settings.Add(_item);
                        }
                        _unitOfWork.Commit();
                        SiteCacher.ClearCache(Site.ID);
                    }

                    objResp              = new FileUploadResponse();
                    objResp.FilePath     = "/upload/sitelogo/" + FileName;
                    objResp.NeedToCrop   = NeedToCrop;
                    objResp.PhysicalPath = strFilePath + "\\" + FileName;
                    objResp.Type         = "logo";
                }
            }
            catch (Exception ex)
            {
                _logger.LogException(ex);
            }
            return(Json(objResp));
        }