Exemplo n.º 1
0
 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();
     }
 }
Exemplo n.º 2
0
 public bool EmailRegistered(string email)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         var result = from o in db.Users
                      where o.Status > 0 && o.Email.Equals(email)
                      select o;
         return result.Count() > 0 ? true : false;
     }
 }
 public int GetRoleID(string RoleName)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         var result = (from o in db.Roles
                       where o.RoleName.Equals(RoleName) && o.Status > 0
                       select o.RoleID).FirstOrDefault();
         return result;
     }
 }
Exemplo n.º 4
0
 public Hub.Models.User GetAccount(Guid userID)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         var result = (from o in db.Users
                       where o.UserID.Equals(userID) && o.Status > 0
                       select o).First();
         return result;
     }
 }
 public int[] GetRole(Guid userid)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         var result = (from o in db.User_Role
                       where o.UserID.Equals(userid) && o.Status > 0
                       select o.RoleID);
         if (result.Count() > 0) return result.ToArray<int>();
         return null;
     }
 }
 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;
     }
 }
Exemplo n.º 7
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 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 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;
     }
 }
Exemplo n.º 10
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;
     }
 }
Exemplo n.º 11
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;
     }
 }
Exemplo n.º 12
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;
     }
 }
Exemplo n.º 13
0
 public bool StuNumberRegistered(string stunumber)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         var result = from o in db.Users
                      where o.Status > 0 && o.StuNumber.Equals(stunumber)
                      select o;
         return result.Count() > 0 ? true : false;
     }
 }
Exemplo n.º 14
0
 public string[] GetNickNameListByUserID(Guid[] useridList)
 {
     string[] nicknameList = new string[useridList.Length];
     using (var db = new ExtensionFrameworkContext())
     {
         for (int i = 0; i < useridList.Length; i++)
         {
             var result = (from o in db.Users
                           where o.UserID.Equals(useridList[i]) && o.Status > 0
                           select o).First();
             nicknameList[i] = result.NickName;
         }
         return nicknameList;
     }
 }
Exemplo n.º 15
0
 public string GetEmailByStuNum(string stunumber)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         var result = (from o in db.Users
                       where o.StuNumber.Equals(stunumber) && o.Status > 0
                       select o).First();
         return result.Email;
     }
 }
Exemplo n.º 16
0
 public List<Guid> GetRoleName(int[] RoleIDList)
 {
     List<Guid> rolenameList = new List<Guid>(RoleIDList.Length);
     using (var db = new ExtensionFrameworkContext())
     {
         foreach (int item in RoleIDList)
         {
             var result = (from o in db.Roles
                           where o.RoleID == item && o.Status > 0
                           select o.RoleName).First();
             rolenameList.Add(new Guid(result));
         }
     }
     return rolenameList;
 }
Exemplo n.º 17
0
 public string GetAvatarByUserID(Guid userid)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         var result = (from o in db.Users
                       where o.UserID.Equals(userid) && o.Status > 0
                       select o.Avatar).First();
         return result;
     }
 }
Exemplo n.º 18
0
 public bool NickNameRegistered(string nickname)
 {
     using (var db = new ExtensionFrameworkContext())
     {
         var result = from o in db.Users
                      where o.Status > 0 && o.NickName.Equals(nickname)
                      select o;
         return result.Count() > 0 ? true : false;
     }
 }