Ejemplo n.º 1
0
        /// <summary>
        /// declares 'StartTime' within the session as equal to the current time
        /// and passes ID and Difficulty to SudokuForView
        /// then passes the returned string to StringToArray
        /// </summary>
        /// <param name="id"></param>
        /// <param name="Difficulty"></param>
        /// <returns></returns>
        public ActionResult Sudoku(int id, string Difficulty)
        {
            Session["StartTime"] = DateTime.Now;

            SudokuOutputView model = new SudokuOutputView();
            SudoCRUD         s     = new SudoCRUD();

            Sudo.Sudo s2   = new Sudo.Sudo();
            string[]  temp = s.SudokuForView(id, Difficulty);

            model.Values   = s2.StringToArray(temp[1]);
            model.SudokuID = id;
            return(View(model));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets all times with the SudokuID of 'ID' and stores them in a 'Leaderboard'
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Leaderboard(int id)
        {
            SudoCRUD GetTimes = new SudoCRUD();
            List <SudoCRUD.LeaderboardEntry> LeaderboardList = GetTimes.GetLeaderboard(id);
            SudokuLeaderboard Output = new SudokuLeaderboard();

            foreach (var item in LeaderboardList)
            {
                LeaderboardEntry temp = new LeaderboardEntry();
                temp.SudokuID  = item.SudokuID;
                temp.TimeTaken = TimeSpan.Parse(item.TimeTaken);
                temp.UserName  = item.UserName;
                Output.AddEntryToList(temp);
            }

            return(View(Output));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// gets all sudokus and their creation date and stores them in an IDictionary which is a list of integers and DateTimes
        /// and returns the IDictionary
        /// </summary>
        /// <returns></returns>
        private SudokuListView GetListViewModel()
        {
            string userID = User.Identity.Name;

            SudokuListView List = new SudokuListView();
            SudoCRUD       s    = new SudoCRUD();
            IDictionary <int, DateTime> DBList = s.SudokuList();

            foreach (var item in DBList)
            {
                SudokuModel temp = new SudokuModel();
                temp.ID           = item.Key;
                temp.CreationDate = item.Value;
                List.AddSudoToList(temp);
            }

            return(List);
        }
Ejemplo n.º 4
0
        public ActionResult SubmitSudoku(int[] ID, int SudokuID)
        {
            string   Solution = string.Join(",", ID);;
            bool     Result;
            SudoCRUD s = new SudoCRUD();

            //Solution = s.ArrayToString(ID);

            Result = s.CheckSudoku(Solution, SudokuID);
            if (Result)
            {
                DateTime StartTime = (DateTime)Session["StartTime"];
                TimeSpan Duration  = DateTime.Now - StartTime;
                string   UserName  = User.Identity.Name;
                s.SaveTime(SudokuID, Duration, UserName);
                return(RedirectToAction("SudokuSuccess"));
            }
            else
            {
                return(RedirectToAction("SudokuFail"));
            }
        }