public T_USER_UserInfo Login(string email, string password) { string pwd = MD5T.MD5Encrypt(password); using (DBGemmyService2 db = new DBGemmyService2()) { var entity = db.T_USER_UserInfo.Where(m => m.Email == email).FirstOrDefault(); if (entity != null) { //判断是否允许登录 if (entity.Password == pwd) { entity.CanLogin = true; } else { entity.NoPassword = true; } return(entity); } else { } } return(null); }
public bool Register(string email, string password, string firstname, string lastname) { bool issuccess = false; using (DBGemmyService2 db = new DBGemmyService2()) { var entity = db.T_USER_UserInfo.Where(m => m.Email == email).ToList(); if (entity.Count == 0) { password = MD5T.MD5Encrypt(password); db.T_USER_UserInfo.Add(new T_USER_UserInfo() { FirstName = firstname, Password = password, LastName = lastname, Email = email }); int n = db.SaveChanges(); if (n > 0) { issuccess = true; } } } return(issuccess); }
public void addResetInfo(string email, DateTime dt, string code) { using (DBGemmyService2 db = new DBGemmyService2()) { var entity = db.T_User_Temporary_UserInfo.Where(m => m.Email == email).ToList(); if (entity.Count == 0) { db.T_User_Temporary_UserInfo.Add(new T_USER_Temporary_UserInfo { Email = email, ResetFailTime = dt, ResetCode = code }); db.SaveChanges(); } else { foreach (var item in entity) { item.ResetCode = code; item.ResetFailTime = dt; } db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = true; } } }
public List <T_USER_UserInfo> getUserinfo(string email) { using (DBGemmyService2 db = new DBGemmyService2()) { var entity = db.T_USER_UserInfo.Where(m => m.Email == email); return(entity.ToList()); } }
/// <summary> /// 查询个体 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="id"></param> /// <returns></returns> public IQueryable <T> GetAllById <T>(int id) where T : T_Base { using (DBGemmyService2 _db = new DBGemmyService2()) { var entity = _db.Set <T>().Where(m => m.Id == id); return(entity); } }
/// <summary> /// 查询全部 /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public IQueryable <T> GetAll <T>() where T : class { using (DBGemmyService2 _db = new DBGemmyService2()) { var entity = _db.Set <T>().AsNoTracking(); return(entity); } }
public List <T_USER_UserInfo> getUserinfoLoginReset(string email, string password) { string pwd = MD5T.MD5Encrypt(password); using (DBGemmyService2 db = new DBGemmyService2()) { var entity = db.T_USER_UserInfo.Where(m => m.Email == email && m.Password == pwd); return(entity.ToList()); } }
public int DeleteEntityByid <T>(int id) where T : class { using (DBGemmyService2 _db = new DBGemmyService2()) { var entity = _db.Set <T>().Find(id); _db.Set <T>().Remove(entity); return(_db.SaveChanges()); } }
//添加 public int AddEntities <T>(T entity) where T : class { using (DBGemmyService2 db = new DBGemmyService2()) { try { db.Entry <T>(entity).State = EntityState.Added; return(db.SaveChanges()); } catch (Exception ex) { return(0); } } }
public int AddT_Office_Files(T_Office_Files model) { //有效性检查 try { using (DBGemmyService2 d = new DBGemmyService2()) { d.T_Office_Files.Add(model); return(d.SaveChanges()); } } catch (Exception) { return(0); } }
public void Reset(string email, string password) { using (DBGemmyService2 db = new DBGemmyService2()) { var entity = db.T_USER_UserInfo.Where(m => m.Email == email).ToList(); if (entity.Count != 0) { foreach (var item in entity) { item.Password = MD5T.MD5Encrypt(password); } db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = true; } } }
public T_USER_UserCompanyInfo getCompanyInfo2(string email) { using (DBGemmyService2 db = new DBGemmyService2()) { T_USER_UserCompanyInfo t = db.T_USER_UserCompanyInfo.FirstOrDefault(m => m.Email == email); if (t == null) { return(new T_USER_UserCompanyInfo() { Email = email, }); } else { return(t); } } }
public int Update <T>(T entity) where T : class { using (DBGemmyService2 dbcontext = new DBGemmyService2()) { dbcontext.Set <T>().Attach(entity); PropertyInfo[] props = entity.GetType().GetProperties(); foreach (PropertyInfo prop in props) { if (prop.GetValue(entity, null) != null) { if (prop.GetValue(entity, null).ToString() == " ") { dbcontext.Entry(entity).Property(prop.Name).CurrentValue = null; } dbcontext.Entry(entity).Property(prop.Name).IsModified = true; } } return(dbcontext.SaveChanges()); } }
public bool addCompanyInfo(T_USER_UserCompanyInfo list) { bool issuccess = false; using (DBGemmyService2 db = new DBGemmyService2()) { if (db.T_USER_UserCompanyInfo.Any(m => m.Email == list.Email)) { Update <T_USER_UserCompanyInfo>(list); issuccess = true; return(issuccess); } else { T_USER_UserCompanyInfo t = new T_USER_UserCompanyInfo(); t = list; db.T_USER_UserCompanyInfo.Add(t); db.SaveChanges(); issuccess = true; } } return(issuccess); }
public int DeleteEntity <T>(string ids) where T : class { using (DBGemmyService2 _db = new DBGemmyService2()) { int suc = 0; string[] idArr = ids.Split(','); foreach (string _id in idArr) { if (_id.Trim() == "") { continue; } int intid = Convert.ToInt32(_id); var entity = _db.Set <T>().Find(intid); _db.Set <T>().Remove(entity); suc += _db.SaveChanges(); } return(suc); } }