public ActionResult UpdateDomain(DomainModel domainSettings) { if (!ModelState.IsValid) return Json(new { success = false }); if (domainSettings.DomainID == 0) return null; var val = domainSettings.SettingsValues.Select(x => new tbl_SettingsValue() { SV_DomainID = x.SV_DomainID, SV_Value = x.SV_Value, SV_SettingsID = x.SV_SettingsID, SettingsValueID = x.SettingsValueID }).ToList(); var socials = domainSettings.Social != null ? domainSettings.Social.Select(x => new tbl_Social() { SocialID = x.SocialID, S_BackColour = x.BackColour, S_ForeColour = x.ForeColour, S_Live = x.Live, S_DefaultBackColour = x.DefaultBackColour, S_DefaultForeColour = x.DefaultForeColour, S_DefaultBorderRadius = x.DefaultBorderRadius, S_Title = x.Title, S_DomainID = domainSettings.DomainID, S_IconClass = x.IconClass, S_URL = x.URL ?? String.Empty, S_BorderRadius = x.BorderRadius }).ToList() : new List<tbl_Social>(); EventViewType eventView; bool parsed = Enum.TryParse<EventViewType>(domainSettings.EventViewType.ToString(), true, out eventView); tbl_Domains domain = DomainService.SaveDomain(domainSettings.DO_CompanyAddress, domainSettings.DO_CompanyName, domainSettings.DO_CompanyTelephone, domainSettings.DO_ConsumerKey, domainSettings.DO_ConsumerSecret, domainSettings.DO_CSS, String.Empty, String.Empty, domainSettings.DO_DefaultLangID.GetValueOrDefault(0), String.Empty, String.Empty, domainSettings.DO_Domain, domainSettings.DO_Email, domainSettings.DO_GoogleAnalytics, domainSettings.DO_GoogleAnalyticsCode, domainSettings.DO_GoogleAnalyticsVisible, domainSettings.DO_Robots, String.Empty, domainSettings.DO_HomePageID, domainSettings.DO_LaunchYear, true, domainSettings.DO_ShareThis, domainSettings.DO_TwitterSecret, domainSettings.DO_TwitterToken, String.Empty, domainSettings.DO_UpdateTwitter, domainSettings.DO_EnableMailChimp, domainSettings.DO_MailChimpAPIKey, domainSettings.DO_MailChimpListID, domainSettings.DO_EnableCommuniGator, domainSettings.DO_CommuniGatorUserName, domainSettings.DO_CommuniGatorPassword, val, domainSettings.IsPaypalPayment, domainSettings.IsSagePayPayment, domainSettings.IsSecureTradingPayment, parsed ? eventView : EventViewType.Calendar, domainSettings.EnableEventSale, domainSettings.EnableProductSale, domainSettings.DO_Theme, domainSettings.DO_DevelopmentMode, domainSettings.DomainID, domainSettings.IsCookieConsentEnabled, domainSettings.IsStripePayment, socials, domainSettings.DO_CustomRouteHandler); if (domain != null) BundleConfig.LoadBundles(); return Json(new { success = domain != null, domainID = domain != null ? domain.DomainID : 0 }); }
public ActionResult DomainSettings(int domainID = 0) { tbl_Domains domain = DomainService.GetDomainByID(domainID); this.ViewBag.Pages = (domain != null) ? WebContentService.GetSitemapListByContent(domain.DomainID, domain.DO_HomePageID) : new List<ExtendedSelectListItem>(); this.ViewBag.EventViewTypes = Enum.GetValues(typeof(EventViewType)).Cast<EventViewType>() .Select(c => new SelectListItem { Text = c.ToString(), Value = ((int)c).ToString() }).ToList(); this.ViewBag.Themes = new SelectList(Directory.GetDirectories(Server.MapPath("/Themes")).Select(d => new { dir = d.Split('\\').Last() }), "dir", "dir"); if (domain == null) { var list = DomainService.GetDefaultSettingsValuesList().Select(x => new SettingsValueModel() { SV_DomainID = 0, SV_Value = x.SE_Value, SV_SettingsID = x.SettingID, SettingsValueID = 0, Settings = new SettingsModel() { SE_Category = x.SE_Category, SE_Type = x.SE_Type, SE_Variable = x.SE_Variable, SE_VariableLabel = x.SE_VariableLabel, SE_Description = x.SE_Description } }).ToList(); var socialList = DomainService.GetDefaultSocialValues(0).Select(s => new SocialModel() { BackColour = s.S_BackColour, ForeColour = s.S_ForeColour, DefaultBackColour = s.S_DefaultBackColour, DefaultForeColour = s.S_DefaultForeColour, Title = s.S_Title, Live = false, IconClass = s.S_IconClass, URL = s.S_URL, BorderRadius = s.S_BorderRadius, DomainID = s.S_DomainID }).ToList(); return PartialView(new DomainModel() { IsPaypalPayment = true, IsSagePayPayment = true, SettingsValues = list, EnableEventSale = true, EnableProductSale = true, DO_EnableMailChimp = false, DO_EnableCommuniGator = false, EventViewType = (int)EventViewType.Calendar }); } else { var list = domain.tbl_SettingsValue.Select(x => new SettingsValueModel() { SV_DomainID = domain.DomainID, SV_Value = x.SV_Value, SV_SettingsID = x.SV_SettingsID, SettingsValueID = x.SettingsValueID, Settings = new SettingsModel() { SE_Category = x.tbl_Settings.SE_Category, SE_Type = x.tbl_Settings.SE_Type, SE_Variable = x.tbl_Settings.SE_Variable, SE_VariableLabel = x.tbl_Settings.SE_VariableLabel, SE_Description = x.tbl_Settings.SE_Description } }).ToList(); var socialList = domain.tbl_Social.Select(x => new SocialModel() { SocialID = x.SocialID, BackColour = x.S_BackColour, ForeColour = x.S_ForeColour, DefaultBackColour = x.S_DefaultBackColour, DefaultForeColour = x.S_DefaultForeColour, DefaultBorderRadius = x.S_DefaultBorderRadius, Title = x.S_Title, Live = x.S_Live, IconClass = x.S_IconClass, URL = x.S_URL, DomainID = x.S_DomainID }).ToList(); List<tbl_PaymentDomain> payments = ECommerceService.GetAllPaymentsDomain(domain.DomainID); var result = new DomainModel() { DomainID = domain.DomainID, DO_CompanyAddress = domain.DO_CompanyAddress, DO_CompanyName = domain.DO_CompanyName, DO_CompanyTelephone = domain.DO_CompanyTelephone, DO_ConsumerKey = domain.DO_ConsumerKey, DO_ConsumerSecret = domain.DO_ConsumerSecret, DO_CSS = domain.DO_CSS, DO_DefaultLangID = domain.DO_DefaultLangID, DO_Domain = domain.DO_Domain, DO_Email = domain.DO_Email, DO_GoogleAnalytics = domain.DO_GoogleAnalytics, DO_GoogleAnalyticsCode = domain.DO_GoogleAnalyticsCode, DO_GoogleAnalyticsVisible = domain.DO_GoogleAnalyticsVisible, DO_Robots = domain.DO_Robots, DO_HomePageID = domain.DO_HomePageID, DO_LaunchYear = domain.DO_LaunchYear, DO_ShareThis = domain.DO_ShareThis, DO_TwitterSecret = domain.DO_TwitterSecret, DO_TwitterToken = domain.DO_TwitterToken, DO_UpdateTwitter = domain.DO_UpdateTwitter, DO_Theme = domain.DO_Theme, DO_EnableMailChimp = domain.DO_EnableMailChimp, DO_MailChimpAPIKey = domain.DO_MailChimpAPIKey, DO_MailChimpListID = domain.DO_MailChimpListID, DO_EnableCommuniGator = domain.DO_EnableCommuniGator, DO_CommuniGatorPassword = domain.DO_CommuniGatorPassword, DO_CommuniGatorUserName = domain.DO_CommuniGatorUserName, EventViewType = domain.DO_DefaultEventView, EnableEventSale = domain.DO_EnableEventSale, EnableProductSale = domain.DO_EnableProductSale, IsCookieConsentEnabled = domain.DO_IsCookieConsentEnabled, DO_CustomRouteHandler = domain.DO_CustomRouteHandler, IsPaypalPayment = payments.Where(m => m.tbl_PaymentType.PT_Code == PaymentType.PayPal.ToString()) .Select(m => m.PD_Live) .FirstOrDefault(), IsSagePayPayment = payments.Where(m => m.tbl_PaymentType.PT_Code == PaymentType.SagePay.ToString()) .Select(m => m.PD_Live) .FirstOrDefault(), IsSecureTradingPayment = payments.Where(m => m.tbl_PaymentType.PT_Code == PaymentType.SecureTrading.ToString()) .Select(m => m.PD_Live) .FirstOrDefault(), IsStripePayment = payments.Where(m => m.tbl_PaymentType.PT_Code == PaymentType.Stripe.ToString()) .Select(m => m.PD_Live) .FirstOrDefault(), SettingsValues = list, Social = socialList }; return PartialView(result); } }