Exemple #1
0
        public ActionResult Index(string[] SelectedItemIds)
        {
            SavedDataHelper sdHlp;
            string          strErr = "";

            try
            {
                if (SelectedItemIds != null && SelectedItemIds.Count() > 0)
                {
                    sdHlp = new SavedDataHelper();
                    if (sdHlp.SaveItem(User.Identity.Name, null, null, "Region", SelectedItemIds, ref strErr))
                    {
                        return(new RedirectResult("~/Channel"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Please select at least one region");
                }
            }
            catch (Exception exc)
            {
                ModelState.AddModelError("", "Unexpected error:" + exc.Message);
            }

            return(Index());
        }
Exemple #2
0
        public ActionResult Index(FilterView model)
        {
            DataSetInfo     clsDSInf = null;
            APIHelper       apiHlp;
            SavedDataHelper sdHlp;
            string          strErr = "";
            bool            blnOk  = false;

            try
            {
                if (model != null && model.DaysOfWeek != null && model.Filter != null)
                {
                    if (model.DaysOfWeek.SelectedItemIds == null ||
                        model.DaysOfWeek.SelectedItemIds.Count() == 0)
                    {
                        strErr = "Please select at least one day";
                    }
                    else
                    {
                        if (model.Filter == null)
                        {
                            apiHlp = new APIHelper();
                            if (apiHlp.GetDataSet(User.Identity.Name, 440, ref clsDSInf, ref strErr) &&
                                clsDSInf != null &&
                                clsDSInf.DayNameAbbrev != null)
                            {
                                model.Filter = new TPFilter(clsDSInf.DayNameAbbrev);
                                blnOk        = true;
                            }
                            else
                            {
                                ModelState.AddModelError("", "Could not retrieve days of the week");
                            }
                        }
                        else
                        {
                            blnOk = model.Filter.Validate(ref strErr);
                        }

                        if (blnOk)
                        {
                            model.Filter.DaysOfWk = model.DaysOfWeek.SelectedItemIds;

                            sdHlp = new SavedDataHelper();
                            if (sdHlp.SaveItem(User.Identity.Name, null, null, "TPFilter", model.Filter, ref strErr))
                            {
                                return(new RedirectResult("~/Result"));
                            }
                        }
                    }
                }
                else
                {
                    strErr = "Please enter some filters";
                }
            }
            catch (Exception exc)
            {
                strErr = "Unexpected error:" + exc.Message;
            }

            ModelState.AddModelError("", strErr);

            return(View(model));
        }