Exemplo n.º 1
0
        public SearchModel(string sTitle)
        {
            string    query       = "select top 10 Editorial.EditorialID, Editorial.UpVote, Editorial.DownVote, Editorial.solution, Problem.Title from Editorial, Problem, [User] where Editorial.approve='Yes' and Editorial.ProblemID=Problem.ProblemID AND Editorial.UserID=[User].UserID and problem.title like '%" + sTitle + "%'";
            DataTable searchTable = new DBHelper().getTable(query);

            // Adding all rows in list
            for (int i = 0; i < searchTable.Rows.Count; i++)
            {
                editorialModel              = new EditorialModel();
                editorialModel.EditorialID  = Convert.ToInt32(searchTable.Rows[i][0].ToString());
                editorialModel.Solution     = searchTable.Rows[i][3].ToString();
                editorialModel.ProblemTitle = searchTable.Rows[i][4].ToString();

                searchList.Add(editorialModel);
            }
        }
Exemplo n.º 2
0
        public AdminModel(int userID)
        {
            string    sql  = "select Point from [User] where UserID=" + userID;
            DataTable dtbl = new DBHelper().getTable(sql);

            Point = Convert.ToInt32(dtbl.Rows[0][0].ToString());
            dtbl.Clear();

            sql  = "select Editorial.EditorialID, Editorial.Solution, Problem.Title from Editorial, Problem where Editorial.ProblemID=Problem.ProblemID and Approve='No'";
            dtbl = new DBHelper().getTable(sql);

            EditorialModel editorialModel;

            for (int i = 0; i < dtbl.Rows.Count; i++)
            {
                editorialModel              = new EditorialModel();
                editorialModel.EditorialID  = Convert.ToInt32(dtbl.Rows[i][0].ToString());
                editorialModel.ProblemTitle = dtbl.Rows[i][2].ToString();
                editorialModel.Solution     = dtbl.Rows[i][1].ToString();

                approvalList.Add(editorialModel);
            }
        }
Exemplo n.º 3
0
        public ProfileModel(int userID)
        {
            string    sql  = "select Point from [User] where UserID=" + userID;
            DataTable dtbl = new DBHelper().getTable(sql);

            Point = Convert.ToInt32(dtbl.Rows[0][0].ToString());
            dtbl.Clear();

            sql  = "select Editorial.EditorialID, Editorial.Solution, Problem.Title from Editorial, Problem where editorial.approve='Yes' and Editorial.UserID=" + userID + " and Editorial.ProblemID=Problem.ProblemID";
            dtbl = new DBHelper().getTable(sql);

            EditorialModel editorialModel;

            for (int i = 0; i < dtbl.Rows.Count; i++)
            {
                editorialModel              = new EditorialModel();
                editorialModel.EditorialID  = Convert.ToInt32(dtbl.Rows[i][0].ToString());
                editorialModel.ProblemTitle = dtbl.Rows[i][2].ToString();
                editorialModel.Solution     = dtbl.Rows[i][1].ToString();

                myEditorialList.Add(editorialModel);
            }


            sql = "select bookmark.bookmarkid, Bookmark.EditorialID, Editorial.Solution, Problem.Title from Editorial, Problem, Bookmark where Bookmark.UserID=" + userID + " and Editorial.EditorialID=Bookmark.EditorialID and Editorial.ProblemID=Problem.ProblemID";
            dtbl.Clear();
            dtbl = new DBHelper().getTable(sql);

            for (int i = 0; i < dtbl.Rows.Count; i++)
            {
                editorialModel              = new EditorialModel();
                editorialModel.EditorialID  = Convert.ToInt32(dtbl.Rows[i][1].ToString());
                editorialModel.ProblemTitle = dtbl.Rows[i][3].ToString();
                editorialModel.Solution     = dtbl.Rows[i][2].ToString();
                editorialModel.BookMarkID   = Convert.ToInt32(dtbl.Rows[i][0].ToString());

                bookmarkList.Add(editorialModel);
            }


            sql = "select Editorial.EditorialID, Editorial.Solution, Problem.Title from Editorial, Problem where Editorial.EditorialID in (select distinct EditorialID from Comment where UserID=" + userID + ") and Editorial.ProblemID=Problem.ProblemID";
            dtbl.Clear();
            dtbl = new DBHelper().getTable(sql);

            for (int i = 0; i < dtbl.Rows.Count; i++)
            {
                editorialModel              = new EditorialModel();
                editorialModel.EditorialID  = Convert.ToInt32(dtbl.Rows[i][0].ToString());
                editorialModel.ProblemTitle = dtbl.Rows[i][2].ToString();
                editorialModel.Solution     = dtbl.Rows[i][1].ToString();

                InvolvmentEditorialList.Add(editorialModel);
            }


            sql = "select Editorial.EditorialID, Editorial.Solution, Problem.Title from Editorial, Problem where editorial.approve='No' and Editorial.UserID=" + userID + " and Editorial.ProblemID=Problem.ProblemID";
            dtbl.Clear();
            dtbl = new DBHelper().getTable(sql);

            for (int i = 0; i < dtbl.Rows.Count; i++)
            {
                editorialModel              = new EditorialModel();
                editorialModel.EditorialID  = Convert.ToInt32(dtbl.Rows[i][0].ToString());
                editorialModel.ProblemTitle = dtbl.Rows[i][2].ToString();
                editorialModel.Solution     = dtbl.Rows[i][1].ToString();

                pendingEditorialList.Add(editorialModel);
            }
        }