public int DeleteAccount(Guid userID)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         var user = db.Users.Where(x => x.UserID.Equals(userID) && x.Status > 0).FirstOrDefault();
         user.Status = -1;
         return db.SaveChanges();
     }
 }
 public bool AddRole(string RoleName)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         Role role = new Role();
         role.RoleName = RoleName;
         role.Status = 1;
         db.Roles.Add(role);
         return db.SaveChanges() > 0;
     }
 }
 public Guid CreateAccount(Hub.Models.User user)
 {
     user.Password = CreateMD5HashCode(user.Password);
     user.RegisterTime = DateTime.Now;
     user.Status = 1;
     using (var db = new ExtensionFrameworkContext())
     {
         db.Users.Add(user);
         db.SaveChanges();
     }
     return user.UserID;
 }
 public bool DelUserRole(Guid UserID, int RoleID)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         var list = db.User_Role.Where(x => x.UserID.Equals(UserID) && x.RoleID == RoleID && x.Status > 0);
         foreach (var item in list)
         {
             item.Status = -1;
         }
         return db.SaveChanges() > 0;
     }
 }
 public bool DelRole(int RoleID)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         var role = db.Roles.Where(x => x.RoleID == RoleID && x.Status > 0).First();
         if (role != null)
         {
             role.Status = -1;
         }
         return db.SaveChanges() > 0;
     }
 }
 public bool Authorize(Guid UserID, int RoleID)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         User_Role user_role = new User_Role();
         user_role.UserID = UserID;
         user_role.RoleID = RoleID;
         user_role.Status = 1;
         db.User_Role.Add(user_role);
         return db.SaveChanges() > 0;
     }
 }
 public bool UpdatePassword(string stunumber, string password)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         var getUser = db.Users.Where(x => x.StuNumber.Equals(stunumber) && x.Status > 0).First();
         if (getUser != null)
         {
             getUser.Password = CreateMD5HashCode(password);
         }
         return db.SaveChanges()>0;
     }
 }
 public bool UpdateAccount(Hub.Models.User user)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         var getUser = db.Users.Where(x => x.UserID.Equals(user.UserID) && x.Status > 0).First();
         if (getUser != null)
         {
             getUser.NickName = user.NickName;
             getUser.Sex = user.Sex;
             //getUser.Avatar = user.Avatar;
             getUser.Tel = user.Tel;
             getUser.TrueName = user.TrueName;
         }
         return db.SaveChanges() > 0;
     }
 }