Exemplo n.º 1
0
        public async Task<ActionResult> SmsSettings(SmsSettingsViewModel model)
        {
            var selectedSite = await siteManager.GetSiteForEdit(model.SiteId);
            // only server admin site can edit other sites settings
            if (selectedSite.Id == siteManager.CurrentSite.Id)
            {
                ViewData["Title"] = sr["SMS Settings"];
            }
            else 
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - SMS Settings"], selectedSite.SiteName);
            }

            if (selectedSite == null)
            {
                this.AlertDanger(sr["oops something went wrong."], true);
                return RedirectToAction("Index");
            }

            if (!ModelState.IsValid)
            {
                return View(model);
            }

            if (model.SiteId == Guid.Empty)
            {
                this.AlertDanger(sr["oops something went wrong, site was not found."], true);
                return RedirectToAction("Index");
            }
            
            selectedSite.SmsFrom = model.SmsFrom;
            selectedSite.SmsClientId = model.SmsClientId;
            selectedSite.SmsSecureToken = model.SmsSecureToken;
            
            await siteManager.Update(selectedSite);
            
            this.AlertSuccess(string.Format(sr["SMS Settings for {0} were successfully updated."],
                        selectedSite.SiteName), true);
            
            if ((siteManager.CurrentSite.IsServerAdminSite)
                && (siteManager.CurrentSite.Id != selectedSite.Id)
                )
            {
                return RedirectToAction("SmsSettings", new { siteId = model.SiteId });
            }

            return RedirectToAction("SmsSettings");
        }
Exemplo n.º 2
0
        public async Task<ActionResult> SmsSettings(SmsSettingsViewModel model)
        {
            ISiteSettings selectedSite = null;
            if (model.SiteGuid == siteManager.CurrentSite.SiteGuid)
            {
                selectedSite = siteManager.CurrentSite;
                ViewData["Title"] = "SMS Settings";
            }
            else if (siteManager.CurrentSite.IsServerAdminSite)
            {
                selectedSite = await siteManager.Fetch(model.SiteGuid);
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - SMS Settings", selectedSite.SiteName);
            }

            if (selectedSite == null)
            {
                this.AlertDanger("oops something went wrong.", true);

                return RedirectToAction("Index");
            }

            if (!ModelState.IsValid)
            {
                return View(model);
            }

            if (model.SiteGuid == Guid.Empty)
            {
                this.AlertDanger("oops something went wrong, site was not found.", true);

                return RedirectToAction("Index");
            }


            selectedSite.SmsFrom = model.SmsFrom;
            selectedSite.SmsClientId = model.SmsClientId;
            selectedSite.SmsSecureToken = model.SmsSecureToken;
            
            bool result = await siteManager.Save(selectedSite);

            if (result)
            {
                this.AlertSuccess(string.Format("SMS Settings for <b>{0}</b> were successfully updated.",
                            selectedSite.SiteName), true);
            }


            if ((siteManager.CurrentSite.IsServerAdminSite)
                && (siteManager.CurrentSite.SiteGuid != selectedSite.SiteGuid)
                )
            {

                return RedirectToAction("SmsSettings", new { siteGuid = model.SiteGuid });
            }

            return RedirectToAction("SmsSettings");

        }
Exemplo n.º 3
0
        public async Task<IActionResult> SmsSettings(
            Guid? siteId,
            int slp = 1)
        {

            //TODO: we need a way to plugin different sms providers by dependency injection
            // and indicate which one is being used in the UI
            // currently using generic labels but only supports twilio

            var selectedSite = await siteManager.GetSiteForEdit(siteId);
            // only server admin site can edit other sites settings
            if (selectedSite.Id != siteManager.CurrentSite.Id)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - SMS Settings"], selectedSite.SiteName);
            }
            else
            {
                ViewData["Title"] = sr["SMS Settings"];
            }

            var model = new SmsSettingsViewModel();
            model.SiteId = selectedSite.Id;
            model.SmsFrom = selectedSite.SmsFrom;
            model.SmsClientId = selectedSite.SmsClientId;
            model.SmsSecureToken = selectedSite.SmsSecureToken;
            
            return View(model);
        }
Exemplo n.º 4
0
        public async Task<IActionResult> SmsSettings(
            Guid? siteGuid,
            int slp = 1)
        {

            //TODO: we need a way to plugin different sms providers by dependency injection
            // and indicate which one is being used in the UI
            // currently using generic labels but only supports twilio

            ISiteSettings selectedSite;
            // only server admin site can edit other sites settings
            if ((siteGuid.HasValue) && (siteGuid.Value != Guid.Empty) && (siteGuid.Value != siteManager.CurrentSite.SiteGuid) && (siteManager.CurrentSite.IsServerAdminSite))
            {
                selectedSite = await siteManager.Fetch(siteGuid.Value);
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - SMS Settings", selectedSite.SiteName);
            }
            else
            {
                selectedSite = siteManager.CurrentSite;
                ViewData["Title"] = "SMS Settings";
            }

            SmsSettingsViewModel model = new SmsSettingsViewModel();
            model.SiteGuid = selectedSite.SiteGuid;
            model.SiteId = selectedSite.SiteId;
            model.SmsFrom = selectedSite.SmsFrom;
            model.SmsClientId = selectedSite.SmsClientId;
            model.SmsSecureToken = selectedSite.SmsSecureToken;
            
            return View(model);

        }