Ejemplo n.º 1
0
        public ActionResult Settings()
        {
            NccWebSite webSite = _webSiteService.LoadAll().FirstOrDefault();

            if (webSite.WebSiteInfos.Count <= 0)
            {
                NccWebSiteInfo _item = new NccWebSiteInfo();
                _item.Language = GlobalContext.WebSite.Language;
                webSite.WebSiteInfos.Add(_item);
            }

            if (GlobalContext.WebSite.IsMultiLangual)
            {
                foreach (var item in SupportedCultures.Cultures)
                {
                    var count = webSite.WebSiteInfos.Where(x => x.Language == item.TwoLetterISOLanguageName).Count();
                    if (count <= 0)
                    {
                        NccWebSiteInfo _item = new NccWebSiteInfo();
                        _item.Language = item.TwoLetterISOLanguageName;
                        webSite.WebSiteInfos.Add(_item);
                    }
                }
            }

            return(View(webSite));
        }
Ejemplo n.º 2
0
        public ActionResult Settings()
        {
            //var webSites = _webSiteService.LoadAll();
            //var cultures = SupportedCultures.Cultures;
            //ViewBag.Languages = new SelectList(cultures.Select(x => new { Value = x.TwoLetterISOLanguageName.ToLower(), Text = x.NativeName.ToString() }).ToList(), "Value", "Text", SetupHelper.Language);
            //ViewBag.CurrentLanguage = CurrentLanguage;

            NccWebSite webSite = _webSiteService.LoadAll().FirstOrDefault();

            if (webSite.WebSiteInfos.Count <= 0)
            {
                NccWebSiteInfo _item = new NccWebSiteInfo();
                _item.Language = GlobalConfig.WebSite.Language;
                webSite.WebSiteInfos.Add(_item);
            }

            if (GlobalConfig.WebSite.IsMultiLangual)
            {
                foreach (var item in SupportedCultures.Cultures)
                {
                    var count = webSite.WebSiteInfos.Where(x => x.Language == item.TwoLetterISOLanguageName).Count();
                    if (count <= 0)
                    {
                        NccWebSiteInfo _item = new NccWebSiteInfo();
                        _item.Language = item.TwoLetterISOLanguageName;
                        webSite.WebSiteInfos.Add(_item);
                    }
                }
            }

            return(View(webSite));
        }
Ejemplo n.º 3
0
        private void CopyNewData(NccWebSite oldEntity, NccWebSite entity)
        {
            var modificationDate = DateTime.Now;

            oldEntity.AllowRegistration = entity.AllowRegistration;
            oldEntity.DateFormat        = entity.DateFormat;
            oldEntity.DomainName        = entity.DomainName;
            oldEntity.EmailAddress      = entity.EmailAddress;
            oldEntity.Language          = entity.Language;
            oldEntity.ModificationDate  = modificationDate;
            oldEntity.ModifyBy          = entity.ModifyBy;
            oldEntity.Name           = entity.Name;
            oldEntity.NewUserRole    = entity.NewUserRole;
            oldEntity.Status         = entity.Status;
            oldEntity.TimeFormat     = entity.TimeFormat;
            oldEntity.TimeZone       = entity.TimeZone;
            oldEntity.IsMultiLangual = entity.IsMultiLangual;
            oldEntity.VersionNumber += 1;
            oldEntity.Metadata       = entity.Metadata;
            oldEntity.EnableCache    = entity.EnableCache;

            foreach (var item in entity.WebSiteInfos)
            {
                var isNew     = false;
                var oldWsInfo = oldEntity.WebSiteInfos.Where(x => x.Language == item.Language).FirstOrDefault();
                if (oldWsInfo == null)
                {
                    isNew                   = true;
                    oldWsInfo               = new NccWebSiteInfo();
                    oldWsInfo.CreateBy      = item.CreateBy;
                    oldWsInfo.CreationDate  = item.CreationDate;
                    oldWsInfo.VersionNumber = item.VersionNumber;
                    oldWsInfo.VersionNumber = 0;
                    oldWsInfo.Language      = item.Language;
                }

                oldWsInfo.Copyrights = item.Copyrights;
                oldWsInfo.FaviconUrl = item.FaviconUrl;
                //oldWsInfo.Language = item.Language;
                oldWsInfo.ModificationDate      = modificationDate;
                oldWsInfo.ModifyBy              = GlobalContext.GetCurrentUserId();
                oldWsInfo.Name                  = item.Name;
                oldWsInfo.PrivacyPolicyUrl      = item.PrivacyPolicyUrl;
                oldWsInfo.SiteLogoUrl           = item.SiteLogoUrl;
                oldWsInfo.SiteTitle             = item.SiteTitle;
                oldWsInfo.Status                = item.Status;
                oldWsInfo.Tagline               = item.Tagline;
                oldWsInfo.TermsAndConditionsUrl = item.TermsAndConditionsUrl;
                oldWsInfo.VersionNumber        += 1;
                oldWsInfo.Metadata              = item.Metadata;

                if (isNew)
                {
                    oldEntity.WebSiteInfos.Add(oldWsInfo);
                }
            }
        }
Ejemplo n.º 4
0
        public ActionResult Settings(NccWebSite website)
        {
            bool   isSuccess             = false;
            string returnMessage         = "Error occoured. Please fill up all field correctly.";
            bool   isMultiLanguageChange = GlobalContext.WebSite.IsMultiLangual == website.IsMultiLangual ? false : true;

            if (ModelState.IsValid)
            {
                NccWebSite prevWebSite = _webSiteService.Get(website.Id, true);
                isSuccess = true;

                #region For default language
                var defaultLangDetails = website.WebSiteInfos.Where(x => x.Language == GlobalContext.WebSite.Language).FirstOrDefault();
                if (defaultLangDetails == null)
                {
                    isSuccess     = false;
                    returnMessage = "Default language data can't be null";
                }
                else
                {
                    //title empty validation
                    if (string.IsNullOrEmpty(defaultLangDetails.SiteTitle))
                    {
                        isSuccess     = false;
                        returnMessage = "Default language Title can't be null";
                    }
                }
                #endregion

                #region Check validation for other languages
                List <NccWebSiteInfo> deletedList = new List <NccWebSiteInfo>();
                foreach (var item in website.WebSiteInfos.Where(x => x.Language != GlobalContext.WebSite.Language).ToList())
                {
                    if (item.Id == 0 && string.IsNullOrEmpty(item.SiteTitle) && string.IsNullOrEmpty(item.Name) && string.IsNullOrEmpty(item.Tagline) && string.IsNullOrEmpty(item.Copyrights) && string.IsNullOrEmpty(item.PrivacyPolicyUrl))
                    {
                        deletedList.Add(item);
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(item.SiteTitle))
                        {
                            isSuccess     = false;
                            returnMessage = "Title can't be null for language " + item.Language;
                        }
                    }
                }

                //Remove empty
                if (isSuccess)
                {
                    foreach (var item in deletedList)
                    {
                        website.WebSiteInfos.Remove(item);
                    }
                }
                #endregion

                #region Operation
                if (isSuccess)
                {
                    if (prevWebSite != null)
                    {
                        if (string.IsNullOrEmpty(prevWebSite.TablePrefix) == false)
                        {
                            website.TablePrefix = prevWebSite.TablePrefix;
                        }
                        website.WebSitePageSize = prevWebSite.WebSitePageSize;
                        website.AdminPageSize   = prevWebSite.AdminPageSize;
                        website.IsShowFullPost  = prevWebSite.IsShowFullPost;
                    }
                    _webSiteService.Update(website);
                    GlobalContext.WebSite = website;
                    ThemeHelper.WebSite   = website;
                    SetupHelper.LoadSetup();
                    SetupHelper.Language = website.Language;
                    SetupHelper.SaveSetup();

                    returnMessage = "Page updated successful";
                    //var successMessage = "Settings updated successfully";
                    if (isMultiLanguageChange)
                    {
                        returnMessage += ". You must <a href=\"/Home/RestartHost\">restart</a> the site.";
                        //TempData["SuccessMessage"] = "You must <a href=\"/Home/RestartHost\">restart</a> the site.";
                        //successMessage += ". You must <a href=\"/Home/RestartHost\">restart</a> the site.";
                        //GlobalConfig.WebSite.IsMultiLangual = false;
                        //ThemeHelper.WebSite.IsMultiLangual = false;
                    }
                }
                #endregion
            }
            else
            {
                //ModelState.AddModelError("Name", "Please check all values and submit again.");
                returnMessage = string.Join("; ", ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage));
            }

            //var cultures = SupportedCultures.Cultures;
            //ViewBag.Languages = new SelectList(cultures.Select(x => new { Value = x.TwoLetterISOLanguageName.ToLower(), Text = x.NativeName.ToString() }).ToList(), "Value", "Text", SetupHelper.Language);

            if (GlobalContext.WebSite.IsMultiLangual)
            {
                foreach (var item in SupportedCultures.Cultures)
                {
                    var count = website.WebSiteInfos.Where(x => x.Language == item.TwoLetterISOLanguageName).Count();
                    if (count <= 0)
                    {
                        NccWebSiteInfo _item = new NccWebSiteInfo();
                        _item.Language = item.TwoLetterISOLanguageName;
                        website.WebSiteInfos.Add(_item);
                    }
                }
            }
            if (isSuccess)
            {
                ShowMessage(returnMessage, MessageType.Success);
            }
            else
            {
                ShowMessage(returnMessage, MessageType.Error);
            }
            return(View(website));
        }