Exemple #1
0
        public async Task <ActionResult> AlertConfig()
        {
            using (AlertConfigDataProvider dataProvider = new AlertConfigDataProvider()) {
                Model model      = new Model {
                };
                AlertConfig data = await dataProvider.GetItemAsync();

                if (data == null)
                {
                    throw new Error(this.__ResStr("notFound", "The Alert settings could not be found"));
                }
                model.SetData(data);
                return(View(model));
            }
        }
Exemple #2
0
        public async Task <ActionResult> AlertConfig_Partial(Model model)
        {
            using (AlertConfigDataProvider dataProvider = new AlertConfigDataProvider()) {
                AlertConfig data = await dataProvider.GetItemAsync();// get the original item

                if (!ModelState.IsValid)
                {
                    return(PartialView(model));
                }
                data = model.GetData(data); // merge new data into original
                model.SetData(data);        // and all the data back into model for final display
                await dataProvider.UpdateConfigAsync(data);

                return(FormProcessed(model, this.__ResStr("okSaved", "Alert settings saved"), NextPage: Manager.ReturnToUrl));
            }
        }
        public async Task <ActionResult> AlertDisplay()
        {
            if (Manager.EditMode)
            {
                return(new EmptyResult());
            }
            if (Manager.IsInPopup)
            {
                return(new EmptyResult());
            }

            bool done = Manager.SessionSettings.SiteSettings.GetValue <bool>("YetaWF_Basics_AlertDone", false);

            if (done)
            {
                return(new EmptyResult());
            }

            using (AlertConfigDataProvider dataProvider = new AlertConfigDataProvider()) {
                AlertConfig config = await dataProvider.GetItemAsync();

                if (config == null || !config.Enabled)
                {
                    return(new EmptyResult());
                }

                if (config.MessageHandling == AlertConfig.MessageHandlingEnum.DisplayOnce)
                {
                    Manager.SessionSettings.SiteSettings.SetValue <bool>("YetaWF_Basics_AlertDone", true);
                    Manager.SessionSettings.SiteSettings.Save();
                }

                DisplayModel model = new DisplayModel()
                {
                    MessageHandling = config.MessageHandling,
                    Message         = config.Message,
                };
                return(View(model));
            }
        }