コード例 #1
0
        public ActionResult Edit([Bind(Include = "ID,UserName,Tel,Address,Age,Sex")] UserMes user)
        {
            //if (ModelState.IsValid)
            //{
            //    db.Entry(user).State = EntityState.Modified;
            //    db.SaveChanges();
            //    return RedirectToAction("Index");
            //}
            //return View(user);

            try
            {
                var m = db.UserMess.Single(s => s.ID == user.ID);
                m.UserName = user.UserName;
                m.Tel      = user.Tel;
                m.Sex      = user.Sex;
                m.Address  = user.Address;
                m.Age      = user.Age;
                db.SaveChanges();
                return(View("Edit", user));
            }
            catch
            {
                return(View(user));
            }
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            UserMes user = db.UserMess.Find(id);

            db.UserMess.Remove(user);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserMes mes = db.UserMess.Find(id);

            if (mes == null)
            {
                return(HttpNotFound());
            }
            return(View(mes));
        }
コード例 #4
0
        // GET: Movies/Delete/5
        public ActionResult Del(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserMes user = db.UserMess.Find(id);

            if (user == null)
            {
                return(HttpNotFound());
            }
            return(View(user));
        }
コード例 #5
0
        public ActionResult Register([Bind(Include = "ID,Email,PassWord,UserName,Tel,Address,Age,Sex")] UserMes user)
        {
            var num = db.UserMess.Where(s => s.Email == user.Email).Count();

            if (num == 0)
            {
                if (ModelState.IsValid)
                {
                    db.UserMess.Add(user);
                    db.SaveChanges();
                    return(RedirectToAction("Index", "Login"));
                }
            }

            return(View());
        }