public ActionResult Edit(int?id)
 {
     if (Session["UserID"] != null && Session["role"].Equals("admin"))
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         using (DBModel db = new DBModel())
         {
             var obj = db.useraccount.Find(id);
             if (obj != null)
             {
                 UserAccountUpdate user = new UserAccountUpdate();
                 user.id        = obj.id;
                 user.user_name = obj.user_name;
                 user.full_name = obj.full_name;
                 user.password  = obj.password;
                 user.email     = obj.email;
                 user.phone     = obj.phone;
                 user.role      = obj.role;
                 user.isValid   = obj.isValid;
                 return(View(user));
             }
             else
             {
                 return(HttpNotFound());
             }
         }
     }
     else
     {
         return(RedirectToAction("Logout", "Account"));
     }
 }
 public ActionResult Edit([Bind] UserAccountUpdate user)
 {
     if (ModelState.IsValid)
     {
         using (DBModel db = new DBModel())
         {
             UserAccount user_current = db.useraccount.Find(user.id);
             user_current.user_name = user.user_name;
             user_current.full_name = user.full_name;
             user_current.email     = user.email;
             user_current.phone     = user.phone;
             user_current.role      = user.role;
             if (!String.IsNullOrEmpty(user.password))
             {
                 user_current.password = user.password;
             }
             db.Entry(user_current).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     return(View(user));
 }