//
        // GET: /PlayerGroupSchedule/Edit/5

        public ActionResult Edit(int id)
        {
            try
            {
                if (Session["UserAccountID"] == null)
                {
                    return(RedirectToAction("Validate", "Login"));
                }
                User user = (User)Session["User"];
                ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"]));
                if (user.IsAdmin)
                {
                    ViewData["txtIsAdmin"] = "true";
                }
                else
                {
                    ViewData["txtIsAdmin"] = "false";
                }

                // Delete a schedule entry if specified
                IPlayerGroupScheduleRepository schedulerep = new EntityPlayerGroupScheduleRepository();
                string scheduleid = Request.QueryString["delete"];
                if (!String.IsNullOrEmpty(scheduleid))
                {
                    schedulerep.DeletePlayerGroupSchedule(Convert.ToInt32(scheduleid));
                }

                // Delete all schedule entries if specified
                string deleteall = Request.QueryString["deleteall"];
                if (!String.IsNullOrEmpty(deleteall))
                {
                    schedulerep.DeletePlayerGroupSchedulesByPlayerGroup(id);
                }

                PlayerGroup playergroup = db.PlayerGroups.Find(id);
                ViewData["PlayerGroupID"]   = id;
                ViewData["PlayerGroupName"] = playergroup.PlayerGroupName;

                ViewData["ScreenList"] = new SelectList(BuildScreenList(), "Value", "Text", "");
                ViewData["HourList"]   = new SelectList(BuildHourList(), "Value", "Text", "");
                ViewData["MinuteList"] = new SelectList(BuildMinuteList(), "Value", "Text", "");

                ViewData["ScheduleHTML"] = BuildScheduleTable(id);

                PlayerGroupSchedule playergroupschedule = new PlayerGroupSchedule();
                return(View(playergroupschedule));
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("PlayerGroupSchedule", "Edit", ex.Message);
                return(RedirectToAction("Index", "ApplicationError"));
            }
        }
        //
        // GET: /PlayerGroupSchedule/Edit/5

        public ActionResult Edit(int id)
        {
            try
            {
                if (Session["UserAccountID"] == null)
                    return RedirectToAction("Validate", "Login");
                User user = (User)Session["User"];
                ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"]));
                if (user.IsAdmin)
                    ViewData["txtIsAdmin"] = "true";
                else
                    ViewData["txtIsAdmin"] = "false";

                // Delete a schedule entry if specified
                IPlayerGroupScheduleRepository schedulerep = new EntityPlayerGroupScheduleRepository();
                string scheduleid = Request.QueryString["delete"];
                if (!String.IsNullOrEmpty(scheduleid))
                {
                    schedulerep.DeletePlayerGroupSchedule(Convert.ToInt32(scheduleid));
                }

                // Delete all schedule entries if specified
                string deleteall = Request.QueryString["deleteall"];
                if (!String.IsNullOrEmpty(deleteall))
                {
                    schedulerep.DeletePlayerGroupSchedulesByPlayerGroup(id);
                }

                PlayerGroup playergroup = db.PlayerGroups.Find(id);
                ViewData["PlayerGroupID"] = id;
                ViewData["PlayerGroupName"] = playergroup.PlayerGroupName;

                ViewData["ScreenList"] = new SelectList(BuildScreenList(), "Value", "Text", "");
                ViewData["HourList"] = new SelectList(BuildHourList(), "Value", "Text", "");
                ViewData["MinuteList"] = new SelectList(BuildMinuteList(), "Value", "Text", "");

                ViewData["ScheduleHTML"] = BuildScheduleTable(id);

                PlayerGroupSchedule playergroupschedule = new PlayerGroupSchedule();
                return View(playergroupschedule);
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("PlayerGroupSchedule", "Edit", ex.Message);
                return RedirectToAction("Index", "ApplicationError");
            }
        }
        private void CreatePlayerGroupSchedule(int playergroupid, int screenid, int day, int hour, int minute)
        {
            try
            {
                IPlayerGroupScheduleRepository schedulerep = new EntityPlayerGroupScheduleRepository();
                schedulerep.DeletePlayerGroupSchedulesByDayTime(playergroupid, day, hour, minute);

                PlayerGroupSchedule pgs = new PlayerGroupSchedule();
                pgs.PlayerGroupID = playergroupid;
                pgs.ScreenID      = screenid;
                pgs.Day           = day;
                pgs.Hour          = hour;
                pgs.Minute        = minute;

                schedulerep.CreatePlayerGroupSchedule(pgs);
            }
            catch { }
        }
        public ActionResult Edit(PlayerGroupSchedule playergroupschedule)
        {
            try
            {
                if (Session["UserAccountID"] == null)
                    return RedirectToAction("Validate", "Login");
                User user = (User)Session["User"];
                ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"]));
                if (user.IsAdmin)
                    ViewData["txtIsAdmin"] = "true";
                else
                    ViewData["txtIsAdmin"] = "false";

                int playergroupid = Convert.ToInt32(Request.Form["txtPlayerGroupID"]);
                int screenid = Convert.ToInt32(Request.Form["lstScreen"]);
                int hour = Convert.ToInt32(Request.Form["lstHour"]);
                int minute = Convert.ToInt32(Request.Form["lstMinute"]);

                if (!String.IsNullOrEmpty(Request.Form["chkSunday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 0, hour, minute);
                if (!String.IsNullOrEmpty(Request.Form["chkMonday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 1, hour, minute);
                if (!String.IsNullOrEmpty(Request.Form["chkTuesday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 2, hour, minute);
                if (!String.IsNullOrEmpty(Request.Form["chkWednesday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 3, hour, minute);
                if (!String.IsNullOrEmpty(Request.Form["chkThursday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 4, hour, minute);
                if (!String.IsNullOrEmpty(Request.Form["chkFriday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 5, hour, minute);
                if (!String.IsNullOrEmpty(Request.Form["chkSaturday"]))
                    CreatePlayerGroupSchedule(playergroupid, screenid, 6, hour, minute);

                IPlayerGroupRepository pgrep = new EntityPlayerGroupRepository();
                PlayerGroup playergroup = pgrep.GetPlayerGroup(playergroupid);
                ViewData["PlayerGroupID"] = playergroupid;
                ViewData["PlayerGroupName"] = playergroup.PlayerGroupName;

                ViewData["ScreenList"] = new SelectList(BuildScreenList(), "Value", "Text", "");
                ViewData["HourList"] = new SelectList(BuildHourList(), "Value", "Text", "");
                ViewData["MinuteList"] = new SelectList(BuildMinuteList(), "Value", "Text", "");

                ViewData["ScheduleHTML"] = BuildScheduleTable(playergroupid);

                return View(playergroupschedule);
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("PlayerGroupSchedule", "Edit", ex.Message);
                return RedirectToAction("Index", "ApplicationError");
            }
        }
        private void CreatePlayerGroupSchedule(int playergroupid, int screenid, int day, int hour, int minute)
        {
            try
            {
                IPlayerGroupScheduleRepository schedulerep = new EntityPlayerGroupScheduleRepository();
                schedulerep.DeletePlayerGroupSchedulesByDayTime(playergroupid, day, hour, minute);

                PlayerGroupSchedule pgs = new PlayerGroupSchedule();
                pgs.PlayerGroupID = playergroupid;
                pgs.ScreenID = screenid;
                pgs.Day = day;
                pgs.Hour = hour;
                pgs.Minute = minute;

                schedulerep.CreatePlayerGroupSchedule(pgs);
            }
            catch { }
        }
 private void CreateExamplePlayerGroupSchedule(int account, int playergroupid, int screenid)
 {
     try
     {
         IPlayerGroupScheduleRepository schedulerep = new EntityPlayerGroupScheduleRepository();
         for (int i = 0; i < 7; i += 1)
         {
             PlayerGroupSchedule schedule = new PlayerGroupSchedule();
             schedule.PlayerGroupID = playergroupid;
             schedule.ScreenID = screenid;
             schedule.Day = i;
             schedule.Hour = 0;
             schedule.Minute = 0;
             schedulerep.CreatePlayerGroupSchedule(schedule);
         }
     }
     catch { }
 }
        public ActionResult Edit(PlayerGroupSchedule playergroupschedule)
        {
            try
            {
                if (Session["UserAccountID"] == null)
                {
                    return(RedirectToAction("Validate", "Login"));
                }
                User user = (User)Session["User"];
                ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"]));
                if (user.IsAdmin)
                {
                    ViewData["txtIsAdmin"] = "true";
                }
                else
                {
                    ViewData["txtIsAdmin"] = "false";
                }

                int playergroupid = Convert.ToInt32(Request.Form["txtPlayerGroupID"]);
                int screenid      = Convert.ToInt32(Request.Form["lstScreen"]);
                int hour          = Convert.ToInt32(Request.Form["lstHour"]);
                int minute        = Convert.ToInt32(Request.Form["lstMinute"]);

                if (!String.IsNullOrEmpty(Request.Form["chkSunday"]))
                {
                    CreatePlayerGroupSchedule(playergroupid, screenid, 0, hour, minute);
                }
                if (!String.IsNullOrEmpty(Request.Form["chkMonday"]))
                {
                    CreatePlayerGroupSchedule(playergroupid, screenid, 1, hour, minute);
                }
                if (!String.IsNullOrEmpty(Request.Form["chkTuesday"]))
                {
                    CreatePlayerGroupSchedule(playergroupid, screenid, 2, hour, minute);
                }
                if (!String.IsNullOrEmpty(Request.Form["chkWednesday"]))
                {
                    CreatePlayerGroupSchedule(playergroupid, screenid, 3, hour, minute);
                }
                if (!String.IsNullOrEmpty(Request.Form["chkThursday"]))
                {
                    CreatePlayerGroupSchedule(playergroupid, screenid, 4, hour, minute);
                }
                if (!String.IsNullOrEmpty(Request.Form["chkFriday"]))
                {
                    CreatePlayerGroupSchedule(playergroupid, screenid, 5, hour, minute);
                }
                if (!String.IsNullOrEmpty(Request.Form["chkSaturday"]))
                {
                    CreatePlayerGroupSchedule(playergroupid, screenid, 6, hour, minute);
                }

                IPlayerGroupRepository pgrep       = new EntityPlayerGroupRepository();
                PlayerGroup            playergroup = pgrep.GetPlayerGroup(playergroupid);
                ViewData["PlayerGroupID"]   = playergroupid;
                ViewData["PlayerGroupName"] = playergroup.PlayerGroupName;

                ViewData["ScreenList"] = new SelectList(BuildScreenList(), "Value", "Text", "");
                ViewData["HourList"]   = new SelectList(BuildHourList(), "Value", "Text", "");
                ViewData["MinuteList"] = new SelectList(BuildMinuteList(), "Value", "Text", "");

                ViewData["ScheduleHTML"] = BuildScheduleTable(playergroupid);

                return(View(playergroupschedule));
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("PlayerGroupSchedule", "Edit", ex.Message);
                return(RedirectToAction("Index", "ApplicationError"));
            }
        }