Example #1
0
        public IActionResult CreateOrEdit([FromBody] JsonData jsonData)
        {
            if (!_permissionUser.CheckAccess(PermissionsName.SystemSetting))
            {
                return(AccessDeniedJson());
            }
            JsonResultHelper       result = new JsonResultHelper();
            SystemSettingViewModel model  = jsonData.model;

            var systemlogo = _globalSettings.CurrentSystemSetting.SystemLogo;

            model.SystemLogo = systemlogo;

            var aboutHomeImage = _globalSettings.CurrentSystemSetting.AboutHomeImage;

            model.AboutHomeImage = aboutHomeImage;

            var promotionImage = _globalSettings.CurrentSystemSetting.PromotionImage;

            model.PromotionImage = promotionImage;
            new SystemSettingMapping().ToEntity(_context, model, "");


            //new ImageHelper().SaveByteArrayAsImage(@"\SystemLogo\", "SystemLogo.jpeg", model.SystemLogo);
            //new ImageHelper().SaveByteArrayAsImage(@"\AboutUs\", "AboutUs.jpeg", model.AboutHomeImage);
            //new SystemSettingMapping().ToEntity(_context, model, "");


            ////End result
            result.Access  = true;
            result.success = true;
            //result.data = Model;
            result.url = jsonData.continueEditing ? Url.Action("PrepareSystemSetting") : Url.Action("Index", "Dashboard");
            return(Json(result));
        }
Example #2
0
        public ActionResult Edit(int Id)
        {
            SystemSettingViewModel modelMap = Mapper.Map <SystemSetting, SystemSettingViewModel>(this._systemSettingService.GetById(Id));

            //Add Locales to model
            AddLocales(_languageService, modelMap.Locales, (locale, languageId) =>
            {
                locale.Id            = modelMap.Id;
                locale.LocalesId     = modelMap.Id;
                locale.Language      = modelMap.Language;
                locale.Status        = modelMap.Status;
                locale.Favicon       = modelMap.Favicon;
                locale.LogoImage     = modelMap.LogoImage;
                locale.MaintanceSite = modelMap.MaintanceSite;
                locale.Hotline       = modelMap.Hotline;
                locale.Email         = modelMap.Email;
                locale.TimeWork      = modelMap.TimeWork;

                locale.Title           = modelMap.GetLocalized(x => x.Title, Id, languageId, false, false);
                locale.FooterContent   = modelMap.GetLocalized(x => x.FooterContent, Id, languageId, false, false);
                locale.Description     = modelMap.GetLocalized(x => x.Description, Id, languageId, false, false);
                locale.MetaTitle       = modelMap.GetLocalized(x => x.MetaTitle, Id, languageId, false, false);
                locale.MetaKeywords    = modelMap.GetLocalized(x => x.MetaKeywords, Id, languageId, false, false);
                locale.MetaDescription = modelMap.GetLocalized(x => x.MetaDescription, Id, languageId, false, false);
                locale.Slogan          = modelMap.GetLocalized(x => x.Slogan, Id, languageId, false, false);
            });

            return(base.View(modelMap));
        }
        public SystemSettingViewModel ToModel(DbSet <SystemSetting> systemSetting, string type)
        {
            SystemSettingViewModel model = new SystemSettingViewModel();

            model.SystemLogo          = systemSetting.Where(a => a.Name == "SystemLogo").FirstOrDefault().Value;
            model.FildLogInNumber     = Convert.ToInt32(systemSetting.Where(a => a.Name == "FildLogInNumber").FirstOrDefault().Value);
            model.SystemContactNumber = systemSetting.Where(a => a.Name == "SystemContactNumber").FirstOrDefault().Value;
            model.SystemLocation      = systemSetting.Where(a => a.Name == "SystemLocation").FirstOrDefault().Value;
            model.Latitude            = systemSetting.Where(a => a.Name == "Latitude").FirstOrDefault().Value;
            model.Longitude           = systemSetting.Where(a => a.Name == "Longitude").FirstOrDefault().Value;
            model.Email               = systemSetting.Where(a => a.Name == "Email").FirstOrDefault().Value;
            model.SMTP                = systemSetting.Where(a => a.Name == "SMTP").FirstOrDefault().Value;
            model.EmailUserName       = systemSetting.Where(a => a.Name == "EmailUserName").FirstOrDefault().Value;
            model.EmailPassword       = systemSetting.Where(a => a.Name == "EmailPassword").FirstOrDefault().Value;
            model.Port                = systemSetting.Where(a => a.Name == "Port").FirstOrDefault().Value;
            model.FooterContactNumber = systemSetting.Where(a => a.Name == "FooterContactNumber").FirstOrDefault().Value;
            model.FooterContactEmail  = systemSetting.Where(a => a.Name == "FooterContactEmail").FirstOrDefault().Value;
            model.FooterAdressEnglish = systemSetting.Where(a => a.Name == "FooterAdressEnglish").FirstOrDefault().Value;
            model.FooterAdressArabic  = systemSetting.Where(a => a.Name == "FooterAdressArabic").FirstOrDefault().Value;
            model.FooterFacebook      = systemSetting.Where(a => a.Name == "FooterFacebook").FirstOrDefault().Value;
            model.FooterTwitter       = systemSetting.Where(a => a.Name == "FooterTwitter").FirstOrDefault().Value;
            model.FooterLinedIn       = systemSetting.Where(a => a.Name == "FooterLinedIn").FirstOrDefault().Value;

            model.FooterCopyRightsEnglish      = systemSetting.Where(a => a.Name == "FooterCopyRightsEnglish").FirstOrDefault().Value;
            model.FooterCopyRightsArabic       = systemSetting.Where(a => a.Name == "FooterCopyRightsArabic").FirstOrDefault().Value;
            model.AboutHomeTitle               = systemSetting.Where(a => a.Name == "AboutHomeTitle").FirstOrDefault().Value;
            model.AboutHomeTitleAR             = systemSetting.Where(a => a.Name == "AboutHomeTitleAR").FirstOrDefault().Value;
            model.AboutHomeSubTitle            = systemSetting.Where(a => a.Name == "AboutHomeSubTitle").FirstOrDefault().Value;
            model.AboutHomeSubTitleAR          = systemSetting.Where(a => a.Name == "AboutHomeSubTitleAR").FirstOrDefault().Value;
            model.AboutHomeDescription         = systemSetting.Where(a => a.Name == "AboutHomeDescription").FirstOrDefault().Value;
            model.AboutHomeDescriptionAR       = systemSetting.Where(a => a.Name == "AboutHomeDescriptionAR").FirstOrDefault().Value;
            model.AboutHomeImage               = systemSetting.Where(a => a.Name == "AboutHomeImage").FirstOrDefault().Value;
            model.AboutHomeFooterDescription   = systemSetting.Where(a => a.Name == "AboutHomeFooterDescription").FirstOrDefault().Value;
            model.AboutHomeFooterDescriptionAr = systemSetting.Where(a => a.Name == "AboutHomeFooterDescriptionAr").FirstOrDefault().Value;


            model.ConditionsDescriptionAr = systemSetting.Where(a => a.Name == "ConditionsDescriptionAr").FirstOrDefault().Value;
            model.ConditionsDescriptionEn = systemSetting.Where(a => a.Name == "ConditionsDescriptionEn").FirstOrDefault().Value;

            //model.PrivacyPolicyTitleAr = systemSetting.Where(a => a.Name == "PrivacyPolicyTitleAr").FirstOrDefault().Value;
            //model.PrivacyPolicyTitleEn = systemSetting.Where(a => a.Name == "PrivacyPolicyTitleEn").FirstOrDefault().Value;
            model.PrivacyPolicyDescriptionAr = systemSetting.Where(a => a.Name == "PrivacyPolicyDescriptionAr").FirstOrDefault().Value;
            model.PrivacyPolicyDescriptionEn = systemSetting.Where(a => a.Name == "PrivacyPolicyDescriptionEn").FirstOrDefault().Value;

            model.BookingCharge          = Convert.ToInt32(systemSetting.Where(a => a.Name == "BookingCharge").FirstOrDefault().Value);
            model.MaxSeat                = Convert.ToInt32(systemSetting.Where(a => a.Name == "MaxSeat").FirstOrDefault().Value);
            model.EmptySeat              = Convert.ToInt32(systemSetting.Where(a => a.Name == "EmptySeat").FirstOrDefault().Value);
            model.PromotionTitle         = systemSetting.Where(a => a.Name == "PromotionTitle").FirstOrDefault().Value;
            model.PromotionTitleAR       = systemSetting.Where(a => a.Name == "PromotionTitleAR").FirstOrDefault().Value;
            model.PromotionDescription   = systemSetting.Where(a => a.Name == "PromotionDescription").FirstOrDefault().Value;
            model.PromotionDescriptionAR = systemSetting.Where(a => a.Name == "PromotionDescriptionAR").FirstOrDefault().Value;
            model.PromotionImage         = systemSetting.Where(a => a.Name == "PromotionImage").FirstOrDefault().Value;

            model.CookieName = _Configuration["System:CookieName"];
            //model.WebSiteVisitor = systemSetting.Where(a => a.Name == "WebSiteVisitor").FirstOrDefault().Value;

            return(model);
        }
Example #4
0
        public ActionResult Create()
        {
            var model = new SystemSettingViewModel();

            //Add locales to model
            AddLocales(_languageService, model.Locales);

            return(base.View(model));
        }
        //
        // GET: /SystemSetting/

        public ActionResult Index()
        {
            var model = new SystemSettingViewModel();

            model.OrganizationID              = Converts.ToTryString(Session[SessionKeyConfig.OrganizationID], "");
            model.OrganizationList            = SystemSettingManager.GetInstance().GetOrganizationList();
            model.Settings                    = SystemSettingManager.GetInstance().GetSystemSettingManagerList(model.OrganizationID);
            Session["SystemSettingViewModel"] = model;
            return(View(model));
        }
Example #6
0
        public async Task <IActionResult> Edit(string name)
        {
            var val = await _sysSettingAppService.GetTenantSettingValue(name);

            var vmModel = new SystemSettingViewModel
            {
                Name  = name,
                Value = val
            };

            return(View("_EditModal", vmModel));
        }
        public ActionResult Index(SystemSettingViewModel model)
        {
            var btnFlag = model.btnName;

            if (btnFlag.Equals("登録"))
            {
                SystemSettingManager.GetInstance().SaveSetting(model.Settings);
            }

            model.OrganizationList            = SystemSettingManager.GetInstance().GetOrganizationList();
            model.Settings                    = SystemSettingManager.GetInstance().GetSystemSettingManagerList(model.OrganizationID);
            Session["SystemSettingViewModel"] = model;
            return(View(model));
        }
Example #8
0
 public SystemSettingViewModel MappinSystemSystting()
 {
     if (_SystemSettingCach == null)
     {
         using (var serviceScope = m_ServiceProvider.CreateScope())
         {
             using (var context = serviceScope.ServiceProvider.GetService <LibraryDbContext>())
             {
                 // you can access your DBContext instance
                 _SystemSettingCach = new SystemSettingMapping().ToModel(context.SystemSettings, "");
             }
         }
     }
     return(_SystemSettingCach);
 }
Example #9
0
        public ActionResult Update(SystemSettingViewModel input)
        {
            CheckPermission(GetLoginInfo().User.Id, GetCurrentUrl(this));
            var parameters = ModelHelper.GetPropertyDictionary <SystemSettingViewModel>(input);
            var result     = PostStandardWithSameControllerAction <object>(this, parameters);

            if (result.IsSuccess)
            {
                TempData["Message"] = result.Message;
                return(RedirectToAction("List"));
            }
            else
            {
                TempData["Error"] = result.Message;
                return(View("Detail", input));
            }
        }
Example #10
0
        public IActionResult CreateOrEditModel([FromBody] int Id)
        {
            if (!_permissionUser.CheckAccess(PermissionsName.SystemSetting))
            {
                return(AccessDeniedJson());
            }
            JsonResultHelper result = new JsonResultHelper();

            result.Access  = true;
            result.success = true;

            SystemSettingViewModel model = _globalSettings.CurrentSystemSetting;

            new SystemSettingMapping().ToEntity(_context, model, "");
            model.Token = DateTime.Now.Ticks.ToString();
            result.data = model;
            //End result
            return(Json(result));
        }
Example #11
0
        public ActionResult Update(SystemSettingViewModel input)
        {
            CheckPermission();
            using (var result = new ResponseResult <object>())
            {
                if (input.ID <= 0 || input.SETTING_VALUE.IsNullOrEmpty())
                {
                    return(ResponseErrorWithJson <object>(result, "参数有误!请检查!"));
                }

                _systemSettingService.Update(p => p.ID == input.ID, t => new T_SYS_SETTING
                {
                    SETTING_VALUE = input.SETTING_VALUE,
                    UPDATE_DATE   = DateTime.Now
                });

                return(ResponseSuccessWithJson <object>(result, "更新配置项成功!"));
            }
        }
Example #12
0
        public void SetSystemSetting(SystemSettingViewModel systemSettingViewModel, Stream stream, string fileName)
        {
            var    settings       = _applicationDbContext.SystemSettings.ToList();
            string oldLogoSetting = null;

            if (stream != null && !string.IsNullOrEmpty(fileName))
            {
                var           logo        = _fileService.SaveFile(stream, fileName);
                SystemSetting logoSetting = settings.FirstOrDefault(x => x.Key == JMSSetting.SystemLogo);
                if (logoSetting == null)
                {
                    logoSetting = new SystemSetting {
                        Key = JMSSetting.SystemLogo
                    };
                    _applicationDbContext.SystemSettings.Add(logoSetting);
                }
                else
                {
                    oldLogoSetting = logoSetting.Value;
                }
                logoSetting.Value = logo;
                _cacheService.DeleteValue(JMSSetting.SystemLogo);
            }
            if (!string.IsNullOrEmpty(systemSettingViewModel.SystemTitle))
            {
                var setting = settings.FirstOrDefault(x => x.Key == JMSSetting.SystemTitle);
                if (setting == null)
                {
                    setting = new SystemSetting {
                        Key = JMSSetting.SystemTitle
                    };
                    _applicationDbContext.SystemSettings.Add(setting);
                }
                setting.Value = systemSettingViewModel.SystemTitle;
                _cacheService.DeleteValue(JMSSetting.SystemTitle);
            }
            _applicationDbContext.SaveChanges();
            if (stream != null && !string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(oldLogoSetting))
            {
                _fileService.RemoveFile(oldLogoSetting);
            }
        }
Example #13
0
 public IActionResult Settings(JMS.Models.SystemAdmin.SystemSettingViewModel model)
 {
     if (ModelState.IsValid)
     {
         var m1 = new SystemSettingViewModel
         {
             SystemTitle = model.SystemTitle,
             SystemLogo  = model.SystemLogo
         };
         _systemService.SetSystemSetting(m1, model.SystemLogoFile?.OpenReadStream(), model.SystemLogoFile?.FileName);
         TempData.Add(Messages.SuccessSettingMessage, Messages.SuccessSettingMessage);
         m1    = _systemService.GetSystemSettings();
         model = new JMS.Models.SystemAdmin.SystemSettingViewModel
         {
             SystemTitle = m1.SystemTitle,
             SystemLogo  = m1.SystemLogo
         };
     }
     return(View(model));
 }
Example #14
0
        public SystemSettingViewModel GetSystemSettings()
        {
            var model = new SystemSettingViewModel()
            {
                SystemLogo  = _configuration[JMSSetting.SystemLogo],
                SystemTitle = _configuration[JMSSetting.SystemTitle]
            };
            var systemSettings = _applicationDbContext.SystemSettings.ToList();
            var setting        = systemSettings.FirstOrDefault(x => x.Key == JMSSetting.SystemLogo);

            if (setting != null)
            {
                model.SystemLogo = _fileService.GetFile(setting.Value);
            }
            setting = systemSettings.FirstOrDefault(x => x.Key == JMSSetting.SystemTitle);
            if (setting != null)
            {
                model.SystemTitle = setting.Value;
            }
            return(model);
        }
Example #15
0
 public SystemSettingView(IUnityContainer container, SystemSettingViewModel viewModel)
 {
     InitializeComponent();
     this.container   = container;
     this.DataContext = viewModel;
 }
Example #16
0
        public ActionResult Create(SystemSettingViewModel model, string ReturnUrl)
        {
            ActionResult action;

            try
            {
                if (!base.ModelState.IsValid)
                {
                    String messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors)
                                                  .Select(v => v.ErrorMessage + " " + v.Exception));
                    base.ModelState.AddModelError("", messages);
                    return(base.View(model));
                }
                else
                {
                    if (model.Status == 1)
                    {
                        IEnumerable <SystemSetting> systemSettings = this._systemSettingService.FindBy((SystemSetting x) => x.Status == 1, false);
                        if (systemSettings.IsAny <SystemSetting>())
                        {
                            foreach (SystemSetting systemSetting1 in systemSettings)
                            {
                                systemSetting1.Status = 0;
                                this._systemSettingService.Update(systemSetting1);
                            }
                        }
                    }

                    if (model.Favicon != null && model.Favicon.ContentLength > 0)
                    {
                        string fileName  = Path.GetFileName(model.Favicon.FileName);
                        string extension = Path.GetExtension(model.Favicon.FileName);
                        fileName = string.Concat("favicon", extension);
                        string str = Path.Combine(base.Server.MapPath(string.Concat("~/", Contains.ImageFolder)), fileName);

                        //Check and delete logo exists
                        if (System.IO.File.Exists(str))
                        {
                            System.IO.File.Delete(str);
                        }

                        model.Favicon.SaveAs(str);
                        model.FaviconImage = string.Concat(Contains.ImageFolder, fileName);
                    }

                    if (model.Logo != null && model.Logo.ContentLength > 0)
                    {
                        string fileName  = Path.GetFileName(model.Logo.FileName);
                        string extension = Path.GetExtension(model.Logo.FileName);
                        fileName = string.Concat("logo", extension);
                        string str = Path.Combine(base.Server.MapPath(string.Concat("~/", Contains.ImageFolder)), fileName);

                        //Check and delete logo exists
                        if (System.IO.File.Exists(str))
                        {
                            System.IO.File.Delete(str);
                        }

                        model.Logo.SaveAs(str);
                        model.LogoImage = string.Concat(Contains.ImageFolder, fileName);
                    }

                    SystemSetting modelMap = Mapper.Map <SystemSettingViewModel, SystemSetting>(model);
                    this._systemSettingService.Create(modelMap);

                    //Update Localized
                    foreach (var localized in model.Locales)
                    {
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Title, localized.Title, localized.LanguageId);
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.FooterContent, localized.FooterContent, localized.LanguageId);
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId);
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId);
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId);
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId);
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.TimeWork, localized.TimeWork, localized.LanguageId);
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Slogan, localized.Slogan, localized.LanguageId);
                    }

                    base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.SystemSetting)));
                    if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\"))
                    {
                        action = base.RedirectToAction("Index");
                    }
                    else
                    {
                        action = this.Redirect(ReturnUrl);
                    }
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                ExtentionUtils.Log(string.Concat("SystemSetting.Create: ", exception.Message));
                base.ModelState.AddModelError("", exception.Message);
                return(base.View(model));
            }
            return(action);
        }
Example #17
0
        public void ToEntity(LibraryDbContext context, SystemSettingViewModel model, string type)
        {
            DbSet <SystemSetting> systemSetting = context.SystemSettings;
            dynamic entity = null;

            #region Global
            entity       = systemSetting.Where(a => a.Name == "SystemLogo").FirstOrDefault();
            entity.Value = model.SystemLogo;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "SystemContactNumber").FirstOrDefault();
            entity.Value = model.SystemContactNumber;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "SystemLocation").FirstOrDefault();
            entity.Value = model.SystemLocation;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "Latitude").FirstOrDefault();
            entity.Value = model.Latitude;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "Longitude").FirstOrDefault();
            entity.Value = model.Longitude;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "FildLogInNumber").FirstOrDefault();
            entity.Value = model.FildLogInNumber.ToString();
            systemSetting.Update(entity);


            #endregion

            #region Email
            entity       = systemSetting.Where(a => a.Name == "Email").FirstOrDefault();
            entity.Value = model.Email;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "SMTP").FirstOrDefault();
            entity.Value = model.SMTP;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "EmailUserName").FirstOrDefault();
            entity.Value = model.EmailUserName;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "EmailPassword").FirstOrDefault();
            entity.Value = model.EmailPassword;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "Port").FirstOrDefault();
            entity.Value = model.Port;
            systemSetting.Update(entity);
            #endregion

            #region Footer


            entity       = systemSetting.Where(a => a.Name == "FooterContactNumber").FirstOrDefault();
            entity.Value = model.FooterContactNumber;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "FooterContactEmail").FirstOrDefault();
            entity.Value = model.FooterContactEmail;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "FooterAdressEnglish").FirstOrDefault();
            entity.Value = model.FooterAdressEnglish;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "FooterAdressArabic").FirstOrDefault();
            entity.Value = model.FooterAdressArabic;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "FooterFacebook").FirstOrDefault();
            entity.Value = model.FooterFacebook;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "FooterTwitter").FirstOrDefault();
            entity.Value = model.FooterTwitter;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "FooterLinedIn").FirstOrDefault();
            entity.Value = model.FooterLinedIn;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "FooterCopyRightsArabic").FirstOrDefault();
            entity.Value = model.FooterCopyRightsArabic;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "FooterCopyRightsEnglish").FirstOrDefault();
            entity.Value = model.FooterCopyRightsEnglish;
            systemSetting.Update(entity);
            #endregion

            #region About Us Home Page

            entity       = systemSetting.Where(a => a.Name == "AboutHomeTitle").FirstOrDefault();
            entity.Value = model.AboutHomeTitle;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "AboutHomeTitleAR").FirstOrDefault();
            entity.Value = model.AboutHomeTitleAR;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "AboutHomeSubTitle").FirstOrDefault();
            entity.Value = model.AboutHomeSubTitle;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "AboutHomeSubTitleAR").FirstOrDefault();
            entity.Value = model.AboutHomeSubTitleAR;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "AboutHomeDescription").FirstOrDefault();
            entity.Value = model.AboutHomeDescription;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "AboutHomeDescriptionAR").FirstOrDefault();
            entity.Value = model.AboutHomeDescriptionAR;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "AboutHomeImage").FirstOrDefault();
            entity.Value = model.AboutHomeImage;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "AboutHomeFooterDescription").FirstOrDefault();
            entity.Value = model.AboutHomeFooterDescription;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "AboutHomeFooterDescriptionAr").FirstOrDefault();
            entity.Value = model.AboutHomeFooterDescriptionAr;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "ConditionsDescriptionAr").FirstOrDefault();
            entity.Value = model.ConditionsDescriptionAr;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "ConditionsDescriptionEn").FirstOrDefault();
            entity.Value = model.ConditionsDescriptionEn;
            systemSetting.Update(entity);



            entity       = systemSetting.Where(a => a.Name == "PrivacyPolicyDescriptionAr").FirstOrDefault();
            entity.Value = model.PrivacyPolicyDescriptionAr;
            systemSetting.Update(entity);
            entity       = systemSetting.Where(a => a.Name == "PrivacyPolicyDescriptionEn").FirstOrDefault();
            entity.Value = model.PrivacyPolicyDescriptionEn;
            systemSetting.Update(entity);

            #endregion

            #region Promotion Page

            entity       = systemSetting.Where(a => a.Name == "PromotionTitle").FirstOrDefault();
            entity.Value = model.PromotionTitle;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "PromotionTitleAR").FirstOrDefault();
            entity.Value = model.PromotionTitleAR;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "PromotionDescription").FirstOrDefault();
            entity.Value = model.PromotionDescription;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "PromotionDescriptionAR").FirstOrDefault();
            entity.Value = model.PromotionDescriptionAR;
            systemSetting.Update(entity);

            entity       = systemSetting.Where(a => a.Name == "PromotionImage").FirstOrDefault();
            entity.Value = model.PromotionImage;
            systemSetting.Update(entity);


            #endregion
            context.SaveChanges();
        }
Example #18
0
        public ActionResult Create(SystemSettingViewModel model, string returnUrl)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var messages = Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors)
                                        .Select(v => v.ErrorMessage + " " + v.Exception));
                    ModelState.AddModelError("", messages);
                    return(View(model));
                }

                if (model.Status == 1)
                {
                    var systemSettings = _systemSettingService.FindBy(x => x.Status == 1);
                    if (systemSettings.IsAny())
                    {
                        foreach (var item in systemSettings)
                        {
                            item.Status = 0;
                            _systemSettingService.Update(item);
                        }
                    }
                }

                if (model.Favicon != null && model.Favicon.ContentLength > 0)
                {
                    var extension = Path.GetExtension(model.Favicon.FileName);
                    var fileName  = Concat("favicon", extension);
                    var path      = Path.Combine(Server.MapPath(Concat("~/", Constant.SystemSettingFolder)), fileName);

                    //Check and delete logo exists
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }

                    model.Favicon.SaveAs(path);
                    model.FaviconImage = Concat(Constant.SystemSettingFolder, fileName);
                }

                if (model.Logo != null && model.Logo.ContentLength > 0)
                {
                    var extension = Path.GetExtension(model.Logo.FileName);
                    var fileName  = Concat("logo", extension);
                    var path      = Path.Combine(Server.MapPath(Concat("~/", Constant.SystemSettingFolder)), fileName);

                    //Check and delete logo exists
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }

                    model.Logo.SaveAs(path);
                    model.LogoImage = Concat(Constant.SystemSettingFolder, fileName);
                }

                if (model.LogoFooter != null && model.LogoFooter.ContentLength > 0)
                {
                    var extension = Path.GetExtension(model.LogoFooter.FileName);
                    var fileName  = Concat("logoFooter", extension);
                    var path      = Path.Combine(Server.MapPath(Concat("~/", Constant.SystemSettingFolder)), fileName);

                    //Check and delete logo exists
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }

                    model.LogoFooter.SaveAs(path);
                    model.LogoFooterImage = Concat(Constant.SystemSettingFolder, fileName);
                }

                var modelMap = Mapper.Map <SystemSettingViewModel, SystemSetting>(model);
                _systemSettingService.Create(modelMap);

                //Update Localized
                foreach (var localized in model.Locales)
                {
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Title, localized.Title, localized.LanguageId);
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.FooterContent, localized.FooterContent, localized.LanguageId);
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId);
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId);
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId);
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId);
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.TimeWork, localized.TimeWork, localized.LanguageId);
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Slogan, localized.Slogan, localized.LanguageId);
                }

                Response.Cookies.Add(new HttpCookie("system_message", Format(MessageUI.CreateSuccess, FormUI.SystemSetting)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    return(RedirectToAction("Index"));
                }

                return(Redirect(returnUrl));
            }
            catch (Exception ex)
            {
                LogText.Log(Concat("SystemSetting.Create: ", ex.Message));
                ModelState.AddModelError("", ex.Message);

                return(View(model));
            }
        }