Exemplo n.º 1
0
        private Dictionary <int, string> SeasonYears()
        {
            var currentSeason = AdminSettingsReader.CurrentSettings().current_season;
            int latestYear    = DateTime.Now.Year;
            int currentMonth  = DateTime.Now.Month;

            if (currentMonth >= 6) //Seasons last from June - June, if True current season must display latest year as current year + 1
            {
                latestYear++;
            }

            Dictionary <int, string> seasonYears = new Dictionary <int, string>(); //Create dictionary file from current season in json file

            for (int i = currentSeason; i > 0; i--)
            {
                string year         = latestYear.ToString();
                string previousYear = (latestYear - 1).ToString();
                if (i == currentSeason)
                {
                    seasonYears.Add(i, "Current ('" + previousYear.Substring(year.Length - 2) + " ~ '" + year.Substring(previousYear.Length - 2) + ")");
                }
                else
                {
                    seasonYears.Add(i, i + " ('" + previousYear.Substring(year.Length - 2) + " ~ '" + year.Substring(previousYear.Length - 2) + ")");
                }
                latestYear--;
            }
            return(seasonYears);
        }
        //Updates Changes in database depending on inputs from the Admin Settings form for recent_definition.
        private void UpdateSubscribers()
        {
            // Retrieve Admin Settings
            dynamic adminSettings = AdminSettingsReader.CurrentSettings();

            // Init variable
            DateTime recentDef = DateTime.Now;

            // Check and see what the recent definition is
            // Then set recentDef to the correct DateTime
            // If there is no selection, recentDef will be set to now
            // No recent subs will be displayed unless they donated at the exact time
            if (!adminSettings.recent_definition.bUsingSpan)
            {
                recentDef = adminSettings.recent_definition.date;
            }
            else if (adminSettings.recent_definition.bUsingSpan)
            {
                recentDef = recentDef.AddMonths(-Convert.ToInt32(adminSettings.recent_definition.span));
            }

            foreach (var subscriber in db.Subscribers)
            {
                if (recentDef >= subscriber.LastDonated)
                {
                    subscriber.RecentDonor = false;
                }
                else
                {
                    subscriber.RecentDonor = true;
                }
            }
            db.SaveChanges();
        }
        public ActionResult Dashboard()
        {
            UpdateAdminSettings();
            AdminSettings current = AdminSettingsReader.CurrentSettings();

            AddViewData(current);
            return(View(current));
        }
Exemplo n.º 4
0
        //returns a Lis<Production> from a List<int> of current season production IDs
        public static List <Production> GetCurrentProductions()
        {
            var               admin         = new AdminController();
            List <int>        currentProdId = AdminSettingsReader.CurrentSettings().current_productions;
            List <Production> currentProd   = admin.db.Productions.Where(p => currentProdId.Contains(p.ProductionId)).OrderBy(p => p.OpeningDay).ToList();

            return(currentProd);
        }
Exemplo n.º 5
0
        //returns a list of Production IDs of current season
        public static List <int> FindCurrentProductions()
        {
            var        admin         = new AdminController();
            int        currentSeason = AdminSettingsReader.CurrentSettings().current_season;
            List <int> result        = admin.db.Productions.Where(p => p.Season == currentSeason).OrderBy(p => p.OpeningDay).
                                       Select(prod => prod.ProductionId).ToList();

            return(result);
        }
        //Section to pass ViewData to controller.
        public void AddViewData(AdminSettings currentSettings)
        {
            currentSettings = AdminSettingsReader.CurrentSettings();
            List <SelectListItem> productionList = GetSelectListItems();

            #region ViewData
            ViewData["ProductionList"]         = productionList;
            ViewData["CurrentProductionList"]  = GetCurrentProductions();
            ViewData["nextSeasonNotification"] = NextSeasonNotification();
            #endregion
        }
Exemplo n.º 7
0
 public ActionResult Dashboard()
 {
     #region ViewData
     List <SelectListItem> productionList = GetSelectListItems();
     ViewData["ProductionList"] = productionList;
     #endregion
     UpdateAdminSettings();
     AdminSettings current = new AdminSettings();
     current = AdminSettingsReader.CurrentSettings();
     ViewData["CurrentProductionList"] = GetCurrentProductions();
     return(View(current));
 }
        // GET: Subscribers/SeasonManager/Create
        public ActionResult Create()
        {
            AdminSettings currentSettings = AdminSettingsReader.CurrentSettings();

            int[] validSeason = new int[] { currentSettings.current_season, currentSettings.current_season + 1 };   //Creates a list of the current season and the next season to populate the Season field
            ViewData["Season"] = new SelectList(validSeason.ToList(), validSeason, "Season");                       //

            if (User.IsInRole("Admin"))                                                                             // this block is used to send a list of names to the user dropdown. If the user isn't an admin, they just see their name.
            {
                ViewData["dbUsers"] = new SelectList(db.Users.ToList(), "ID", "UserName");
            }
            else
            {
                ViewData["dbUsers"] = new SelectList(db.Users.Where(name => name.UserName == User.Identity.Name).ToList(), "ID", "UserName");
            }

            ViewBag.HasAccess = (User.IsInRole("Admin") || User.IsInRole("Subscriber")) ?  true : false;   // this sets a viewbag property which is used to disable forms based on the user's access.
            return(View());
        }
        public ActionResult BugTabStateUpdate(BugReportTab bugreport)
        {
            string filepath = Server.MapPath(Url.Content("~/AdminSettings.json"));

            //Get the current settings
            AdminSettings currentAdminSettings = AdminSettingsReader.CurrentSettings();

            //Insert our new value
            currentAdminSettings.BugReport = bugreport;

            //Convert to json
            string newJson = JsonConvert.SerializeObject(currentAdminSettings, Formatting.Indented);

            //Write to file
            using (StreamWriter writer = new StreamWriter(filepath))
            {
                writer.Write(newJson);
            }
            //make Ajax happy with a success message
            return(Json(new { success = true, message = $"tab_open: {bugreport.tab_open}" }));
        }
Exemplo n.º 10
0
        public ActionResult SettingsUpdate(AdminSettings currentAdminSettings)
        {
            currentAdminSettings.models_missing_photos = AdminSettingsReader.CurrentSettings().models_missing_photos;
            currentAdminSettings.BugReport             = AdminSettingsReader.CurrentSettings().BugReport;

            string newSettings = JsonConvert.SerializeObject(currentAdminSettings, Formatting.Indented);

            newSettings = newSettings.Replace("T00:00:00", "");
            string filepath    = Server.MapPath(Url.Content("~/AdminSettings.json"));
            string oldSettings = null;

            using (StreamReader reader = new StreamReader(filepath))
            {
                oldSettings = reader.ReadToEnd();
            }
            dynamic oldJSON = JObject.Parse(oldSettings);
            dynamic newJSON = JObject.Parse(newSettings);

            int thisSeason = AutoCalculateCurrentSeason();

            if (newJSON.current_season != thisSeason)
            {
                ModelState.AddModelError("current_season", "You have entered the incorrect Season number.");
            }
            //if (oldJSON.season_productions != newJSON.season_productions)
            //{
            //    UpdateProductions(newJSON);
            //}
            using (StreamWriter writer = new StreamWriter(filepath))
            {
                writer.Write(newSettings);
            }
            UpdateAdminSettings();
            currentAdminSettings = AdminSettingsReader.CurrentSettings();
            AddViewData(currentAdminSettings);

            UpdateSubscribers();

            return(View("Dashboard", currentAdminSettings));
        }
Exemplo n.º 11
0
        // GET: Productions/Details/id
        public ActionResult Details(int?id)
        {
            AdminSettings adminSettings = AdminSettingsReader.CurrentSettings();

            if (id == null)
            {
                id = adminSettings.on_stage;
            }
            Production production = db.Productions.Find(id);

            if (production == null)
            {
                return(HttpNotFound());
            }
            List <int> positions = new List <int>()
            {
                0, 1, 3, 2, 4
            };

            ViewBag.Positions = positions;
            return(View(production));
        }
Exemplo n.º 12
0
 public ActionResult Create()
 {
     ViewData["current_season"] = AdminSettingsReader.CurrentSettings().current_season;
     return(View());
 }