Example #1
0
        public static user Update(user user)
        {
            try
            {
                user.roleName = RoleConstant.Member;
                user.status = "active";
                user current = db.users.Find(user.userID);
                if (string.IsNullOrEmpty(user.password))
                {
                    user.password = current.password;
                }
                else
                {
                    user.password = UserService.EncodePass(user.password);
                }
                user.userName = current.userName;
                db.Entry(current).CurrentValues.SetValues(user);
                db.SaveChanges();
            }
            catch (Exception)
            {
                return null;
            }

            return user;
        }
Example #2
0
 public ActionResult Edit(user user)
 {
     if (ModelState.IsValid)
     {
         UserBusiness.Update(user);
         return RedirectToAction("Index");
     }
     return PartialView("EditForm", user);
 }
Example #3
0
        public ActionResult Create(user user)
        {
            if (ModelState.IsValid)
            {
                UserBusiness.Add(user);
                return RedirectToAction("Index");
            }

            return PartialView("CreateForm", user);
        }
Example #4
0
 public static user Add(user user)
 {
     try
     {
         user.password = UserService.EncodePass(user.password);
         user.roleName = RoleConstant.Member;
         user.status = "active";
         db.users.Add(user);
         //endcode pass word
         db.SaveChanges();
     }
     catch (Exception)
     {
         return null;
     }
     return user;
 }