Exemple #1
0
        //增加用户
        public User addUser(string uName, string uEmail, string uPsw)
        {
            User user = new User();

            user.UName = uName;
            user.UEmail = uEmail;
            user.UPassword = uPsw;
            user.UPhoto = "/Content/res/1-1.jpg";

            db.Users.Add(user);
            db.SaveChanges();

            return user;
        }
Exemple #2
0
        public ActionResult update(int id)
        {
            if (Request.IsAjaxRequest())
            {
                var c = 0;
                lock (typeof(Environment))
                {
                    if (c != 1)
                    {
                        string content = Request.Form["comment"];
                        addComment(content, id);
                        c = 1;
                    }
                    //int qid = db.Answers.FirstOrDefault(d => d.AID == id).AQuestionID;
                    var CA = new CtoA();
                    CA.comments = db.Comments.Where(d => d.CAnswerID == id);
                    CA.users = new List<User>();
                    CA.uID = getCookie("id");
                    for (var i = 0; i < CA.comments.Count(); i++)
                    {
                        CA.aID = CA.comments.ToList()[i].CAnswerID;
                        var temp = new User();
                        int uId = CA.comments.ToList()[i].CUserID;
                        temp = db.Users.First(d => d.UID == uId);
                        CA.users.Add(temp);
                    }
                    return PartialView("comment", CA);
                }

            }
            else return new EmptyResult();
        }
Exemple #3
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index", "people");
     }
     return View(user);
 }