Exemplo n.º 1
0
        public bool TryGetValue(int key, out CacheObstacle value)
        {
            bool found = obstacles.TryGetValue(key, out value);

            if (found && value.RefreshRemovalCounter < 0)
            {
                RemovalList.Remove(key);                //we exclude this from being removed..
            }

            return(found);
        }
        public ActionResult RemoveStudent()
        {
            String selectedclass    = TempData["Class"].ToString();
            string connectionString = @"Data Source=msi;Initial Catalog=SEFASSIGNMENT;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";

            System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(connectionString);

            sqlConnection.Open();

            System.Data.SqlClient.SqlCommand sqlCommand = new System.Data.SqlClient.SqlCommand("SELECT Stu_ID FROM [SEFASSIGNMENT].[dbo].[Student] WHERE CLASS_ID='" + selectedclass + "'");
            sqlCommand.Connection = sqlConnection;

            SqlDataReader myreader      = sqlCommand.ExecuteReader();
            List <String> StudentIDList = new List <String>();

            while (myreader.Read())
            {
                StudentIDList.Add(myreader[0].ToString());
            }

            myreader.Close();

            sqlCommand            = new System.Data.SqlClient.SqlCommand("SELECT Stu_Name FROM [SEFASSIGNMENT].[dbo].[Student] WHERE CLASS_ID='" + selectedclass + "'");
            sqlCommand.Connection = sqlConnection;
            SqlDataReader newmyreader     = sqlCommand.ExecuteReader();
            List <String> StudentNameList = new List <String>();

            while (newmyreader.Read())
            {
                StudentNameList.Add(newmyreader[0].ToString());
            }

            newmyreader.Close();
            sqlConnection.Close();

            List <RemoveStudent> Student = new List <RemoveStudent>();

            for (int i = 0; i < StudentIDList.Count; i++)
            {
                Student.Add(new RemoveStudent()
                {
                    StudentID = StudentIDList[i], StudentName = StudentNameList[i], IsCheck = false
                });
            }

            RemovalList CL = new RemovalList();

            CL.ViewRemoveList = Student;

            return(View(CL));
        }
        public ActionResult RemoveStudent(RemovalList cl, string action)
        {
            if (action.Equals("home"))
            {
                return(RedirectToAction("HomeLec", "HomeLec"));
            }

            else if (action.Equals("back"))
            {
                return(RedirectToAction("ManageClass"));
            }

            else if (action.Equals("remove"))
            {
                int           counter        = 0;
                List <String> removelistid   = new List <String>();
                List <String> removelistname = new List <String>();
                foreach (var item in cl.ViewRemoveList)
                {
                    if (item.IsCheck)
                    {
                        counter++;
                        removelistid.Add(item.StudentID);
                        removelistname.Add(item.StudentName);
                    }
                }

                if (counter == 0)
                {
                    TempData["AlertMessage"] = "You selected none student to be removed!";

                    return(RedirectToAction("ManageClass"));
                }

                else
                {
                    TempData["StudentRemovalID"]   = removelistid;
                    TempData["StudentRemovalName"] = removelistname;

                    return(RedirectToAction("ConfirmRemoval"));
                }
            }
            return(View());
        }