public bool Validate(LogInModel model, ISchoolAdministratorDal schooldal = null, IGenerUserDal genUserdal = null) { bool IsLog = true; var GetEntitypasswrod = ""; var sha256Password = ""; ICreateSha256Passwrod sha256 = new AdministratorRegisterBll(); sha256Password = sha256.CreateSha256Passsword(model.Password); if (schooldal == null)//如果schoolDal==null说明我们正在使用普通用户登录 { var entity = genUserdal.GetEntity(model.Account); if (entity != null) { GetEntitypasswrod = entity.Password; } } else { var entity = schooldal.GetEntity(model.Account); if (entity != null) { GetEntitypasswrod = entity.AdministratorPassword; } } if (sha256Password != GetEntitypasswrod) { IsLog = false; } return(IsLog); }
public bool UpData(IEnumerable <SchoolAdministrator> datas, ISchoolAdministratorDal dal) { if (datas == null || dal == null) { return(false); } bool updateIsFun = true; try { foreach (var data in datas) { if (data == null) { continue; } var entity = dal.GetEntity(data.AdministratorAccount); entity.CreateAdminitratorDetialDatas.IsFreeze = data.CreateAdminitratorDetialDatas.IsFreeze; bool isUp = dal.Update(entity); } } catch (Exception e) { updateIsFun = false; } return(updateIsFun); }
/// <summary> /// 如果返回True表示数据库中已存在该用户 /// </summary> /// <param name="schoolAdministrator">用户提交的注册账户信息</param> /// <param name="dal">访问层</param> /// <returns></returns> public bool DatabaseHasEntity(SchoolAdministrator schoolAdministrator, ISchoolAdministratorDal dal) { var entitys = dal.GetEntityForExpress(x => x.AdministratorAccount == schoolAdministrator.AdministratorAccount); if (!(entitys.Count() <= 0)) { return(true); } return(false); }
/// <summary> /// 检查数据库中是否存在该账户且邮箱与其绑定 /// </summary> /// <param name="account"></param> /// <param name="email"></param> /// <param name="dal"></param> /// <returns></returns> public SchoolAdministrator UnCheck(string account, string email, ISchoolAdministratorDal dal) { var entity = dal.GetEntity(account); if (entity == null) { return(null); } if (entity.CreateAdminitratorDetialDatas.Email == email) { return(entity); } return(null); }
public bool ValidateAccount(SchoolAdministrator administrator, ISchoolAdministratorDal dal) { bool IsLog = true; bool createdSha256 = true; try { var entity = dal.GetEntity(administrator.AdministratorAccount); ICreateSha256Passwrod sha256 = new AdministratorRegisterBll(); try { var sha256Password = sha256.CreateSha256Passsword(administrator.AdministratorPassword); if (sha256Password != entity.AdministratorPassword) { IsLog = false; } } catch (Exception e) { throw new ArgumentException("sha256创建失败"); createdSha256 = false; } } catch (Exception e) { if (createdSha256) { throw new NullReferenceException("不存在该账户"); } else { throw new ArgumentException(e.Message); } } return(IsLog); }
public bool CreateValidateSeendToEmail(SchoolAdministrator account, string email, IRegisterValidateCodeDal dal, ISchoolAdministratorDal scdal) { bool CreateGuidIsTrue = true; string guid = ""; //创建验证码并发送使用全球唯一标识符 try { guid = Guid.NewGuid().ToString(); account.ValidateCodes = new RegisterAdministartorValidateCode() { ValidateCode = guid }; scdal.Update(account); } catch (Exception e) { IErrorDatabaseDal errorDal = new ErrorDatabaseDal(ConfigurationManager.AppSettings["assembly"]); ErrorDatabase error = new ErrorDatabase() { DateTime = DateTime.Now, ErrorMessage = e.StackTrace.ToString() }; errorDal.AddEntity(error); CreateGuidIsTrue = false; } if (CreateGuidIsTrue) { ICreateEmail cre = new CreateEnail(); var seendOk = cre.SeendEmail(account.AdministratorAccount, email, guid); if (!seendOk) { CreateGuidIsTrue = false; } } return(CreateGuidIsTrue); }
/// <summary> /// 完善管理员注册的系统信息,并将权限冻结 /// </summary> /// <param name="school">SchoolAdministrator</param> /// <param name="cre">CreateAdminitratorDetialData</param> /// <param name="dal">ISchoolAdministratorDal</param> /// <returns>true/false</returns> public bool RegisterBll(SchoolAdministrator school, CreateAdminitratorDetialData cre, ISchoolAdministratorDal dal) { school.AdministratorPassword = CreateSha256Passsword(school.AdministratorPassword); cre.CreatedTime = DateTime.Now; cre.IsFreeze = true;//IsFreeze:是否冻结 school.CreateAdminitratorDetialDatas = cre; var num = dal.AddEntity(school); return(num > 0); }