예제 #1
0
        public List <Dictionary <String, Object> > GetReplyListById(int id)
        {
            List <Dictionary <String, Object> > list = new List <Dictionary <string, object> >();
            var context = new LOJEntities3();
            var discuss = from e in context.DiscussComments where e.discussid == id select e;

            foreach (var t in discuss)
            {
                Dictionary <String, Object> hash = new Dictionary <string, object>();
                User user = UserInfoController.getUser((int)t.userid);
                hash.Add("uid", user.id);
                hash.Add("name", user.name);
                hash.Add("phone", user.phone);
                hash.Add("avator", user.avator);
                // hash.Add("replynum", t.DiscussComments.Count());
                hash.Add("tid", t.discussid);
                hash.Add("msg", t.comment);
                hash.Add("time", t.time);
                hash.Add("commentid", t.commentid);
                hash.Add("commentNum", getReplyListNum((int)t.discussid));
                list.Add(hash);
            }
            return(list);
        }
예제 #2
0
        public Dictionary <String, Object> GetProblemById(int id)
        {
            var context = new LOJEntities3();
            var problem = from e in context.QuestionSets where e.id == id select e;

            foreach (var t in problem)
            {
                Dictionary <String, Object> hash = new Dictionary <string, object>();
                User user = UserInfoController.getUser((int)t.userid);
                hash.Add("uid", user.id);
                hash.Add("name", user.name);
                hash.Add("phone", user.phone);
                hash.Add("avator", user.avator);
                hash.Add("category", t.category);
                hash.Add("difficulty", t.difficulty);
                hash.Add("problemID", t.id);
                hash.Add("problemInfo", t.queInfo);
                hash.Add("source", t.source);
                hash.Add("time", t.time);
                hash.Add("title", t.title);
                return(hash);
            }
            return(null);
        }
예제 #3
0
        public List <Dictionary <String, Object> > GetFriendList(int uid)
        {
            List <Dictionary <String, Object> > list = new List <Dictionary <string, object> >();
            var context = new LOJEntities3();
            var user    = from e in context.Friends where e.id1 == uid || e.id2 == uid select e;

            foreach (var u in user)
            {
                int id = (int)u.id1;
                if (id == uid)
                {
                    id = (int)u.id2;
                }
                User user2 = getUser(id);
                Dictionary <String, Object> hash = new Dictionary <string, object>();
                hash.Add("userid", user2.id);
                hash.Add("username", user2.name);
                hash.Add("phone", user2.phone);
                hash.Add("time", user2.time);
                hash.Add("avator", user2.avator);
                list.Add(hash);
            }
            return(list);
        }
예제 #4
0
        public Dictionary <String, Object> GetUserInfo(int uid)
        {
            var context = new LOJEntities3();
            var user    = from e in context.Users where e.id == uid select e;

            if (user == null)
            {
                return(null);
            }
            else
            {
                foreach (var u in user)
                {
                    Dictionary <String, Object> hash = new Dictionary <string, object>();
                    hash.Add("userid", u.id);
                    hash.Add("username", u.name);
                    hash.Add("phone", u.phone);
                    hash.Add("time", u.time);
                    hash.Add("avator", u.avator);
                    return(hash);
                }
            }
            return(null);
        }
예제 #5
0
        public Dictionary <String, Object> GetUserLogin(String email, String password)
        {
            var context        = new LOJEntities3();
            var useridentified = from e in context.User_Identified where e.email == email select e;

            if (useridentified == null)
            {
                return(null);
            }
            else
            {
                foreach (var u in useridentified)
                {
                    Console.WriteLine("666");
                    String pwd = Encrypt(password);
                    if (pwd != u.password)
                    {
                        return(null);
                    }
                    else
                    {
                        var  context2 = new LOJEntities3();
                        User user     = context2.Users.Find(u.userid);
                        Dictionary <String, Object> hash = new Dictionary <string, object>();
                        hash.Add("userid", user.id);
                        hash.Add("username", user.name);
                        hash.Add("phone", user.phone);
                        hash.Add("email", u.email);
                        hash.Add("time", user.time);
                        hash.Add("avator", user.avator);
                        return(hash);
                    }
                }
            }
            return(null);
        }
예제 #6
0
        public List <Dictionary <String, Object> > GetDiscussList(int id)
        {
            List <Dictionary <String, Object> > list = new List <Dictionary <string, object> >();
            var context  = new LOJEntities3();
            var solution = from e in context.Solutions where e.questionid == id select e;

            foreach (var t in solution)
            {
                Dictionary <String, Object> hash = new Dictionary <string, object>();
                User user = UserInfoController.getUser((int)t.userid);
                hash.Add("uid", user.id);
                hash.Add("name", user.name);
                hash.Add("phone", user.phone);
                hash.Add("avator", user.avator);
                hash.Add("solution", t.comment);
                hash.Add("msg", t.comment);
                hash.Add("time", t.answerTime);
                hash.Add("questionid", t.questionid);
                hash.Add("solutionid", t.solutionid);
                hash.Add("comments", GetDiscussReplyList(t.solutionid));
                list.Add(hash);
            }
            return(list);
        }