コード例 #1
0
        public SecureHash ResetPassword(long userLoginId, string password, bool userVerified = true)
        {
            using (IDataAccessAdapter myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var userLoginEntity = new UserLoginEntity(userLoginId);

                if (myAdapter.FetchEntity(userLoginEntity))
                {
                    userLoginEntity.IsNew = false;
                    var securehash = _oneWayHashingService.CreateHash(password);
                    userLoginEntity.Password = securehash.HashedText;
                    userLoginEntity.Salt     = securehash.Salt;

                    userLoginEntity.UserVerified           = userVerified;
                    userLoginEntity.LastPasswordChangeDate = DateTime.Now;
                    if (userVerified)
                    {
                        userLoginEntity.ResetPwdQueryString = null;
                    }
                    myAdapter.SaveEntity(userLoginEntity, true);
                    return(securehash);
                }
                return(null);
            }
        }
コード例 #2
0
ファイル: VanRepository.cs プロジェクト: sahvishal/matrix
        public Van GetVan(long vanId)
        {
            var vanDetailsEntity = new VanDetailsEntity(vanId);

            using (IDataAccessAdapter myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                if (!myAdapter.FetchEntity(vanDetailsEntity))
                {
                    throw new ObjectNotFoundInPersistenceException <Van>(vanId);
                }
            }
            return(_mapper.Map(vanDetailsEntity));
        }
コード例 #3
0
        public bool Save(LoginOtp loginOtp)
        {
            var loginOtpEntity = Mapper.Map <LoginOtp, LoginOtpEntity>(loginOtp);

            using (IDataAccessAdapter myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                loginOtpEntity.IsNew = !myAdapter.FetchEntity(new LoginOtpEntity(loginOtp.UserLoginId));;
                if (!myAdapter.SaveEntity(loginOtpEntity, false))
                {
                    throw new PersistenceFailureException();
                }
                return(true);
            }
        }
コード例 #4
0
        public bool Save(LoginSettings loginSettings)
        {
            var loginSettingsEntity = Mapper.Map <LoginSettings, LoginSettingsEntity>(loginSettings);

            using (IDataAccessAdapter adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                loginSettingsEntity.IsNew = !adapter.FetchEntity(new LoginSettingsEntity(loginSettings.UserLoginId));

                if (!adapter.SaveEntity(loginSettingsEntity, false))
                {
                    throw new PersistenceFailureException();
                }
                return(true);
            }
        }
コード例 #5
0
        public bool SaveSecurityQuestionAnswer(long userLoginId, string question, string answer)
        {
            using (IDataAccessAdapter myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var userLoginEntity = new UserLoginEntity(userLoginId);

                if (myAdapter.FetchEntity(userLoginEntity))
                {
                    userLoginEntity.IsNew        = false;
                    userLoginEntity.HintQuestion = question;
                    userLoginEntity.HintAnswer   = _cryptographyService.Encrypt(answer);
                    userLoginEntity.IsSecurityQuestionVerified = true;
                    myAdapter.SaveEntity(userLoginEntity, true);
                    return(true);
                }
                return(false);
            }
        }
コード例 #6
0
ファイル: HomeModule.cs プロジェクト: dfoxpv/MsDev
        private LogDetailModel GetLogDetail(string logDetailPk, string environment)
        {
            Guid logDetailPkGuid;

            if (!Guid.TryParse(logDetailPk, out logDetailPkGuid))
            {
                return(null);
            }

            using (IDataAccessAdapter adapter = AdapterFactory.CreateAdapter(MyNameSpace, environment))
            {
                var toFetch  = new LogDetailEntity(logDetailPkGuid);
                var prefetch = new PrefetchPath2(EntityType.LogDetailEntity)
                {
                    LogDetailEntity.PrefetchPathPhysician
                };
                var fetchResult = adapter.FetchEntity(toFetch, prefetch);
                return(!fetchResult ? null : new LogDetailModel(toFetch));
            }
        }
コード例 #7
0
        public UserLogin UpdateLoginStatus(long userLoginId, bool isSuccessfulLogin)
        {
            using (IDataAccessAdapter myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var userLoginEntity = new UserLoginEntity(userLoginId);
                if (myAdapter.FetchEntity(userLoginEntity))
                {
                    userLoginEntity.IsNew         = false;
                    userLoginEntity.LoginAttempts = isSuccessfulLogin ? 0 : ++userLoginEntity.LoginAttempts;
                    userLoginEntity.IsLocked      = isSuccessfulLogin
                                                   ? false
                                                   : userLoginEntity.LoginAttempts >= 5;

                    userLoginEntity.LastLoginAttemptAt = isSuccessfulLogin ? null : (DateTime?)DateTime.Now;
                    userLoginEntity.LastLogged         = isSuccessfulLogin ? DateTime.Now : userLoginEntity.LastLogged;
                    myAdapter.SaveEntity(userLoginEntity, true);
                    return(_userLoginFactory.CreateUserLogin(userLoginEntity));
                }
                return(null);
            }
        }
コード例 #8
0
        public SecureHash ForceChangePassword(long userLoginId, string password, bool forceChangePassword)
        {
            var userLoginEntity = new UserLoginEntity(userLoginId);
            var securehash      = _oneWayHashingService.CreateHash(password);

            using (IDataAccessAdapter myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                if (myAdapter.FetchEntity(userLoginEntity))
                {
                    userLoginEntity.IsNew = false;

                    userLoginEntity.Password               = securehash.HashedText;
                    userLoginEntity.Salt                   = securehash.Salt;
                    userLoginEntity.UserVerified           = forceChangePassword ? false : true;
                    userLoginEntity.LastPasswordChangeDate = DateTime.Now;
                    myAdapter.SaveEntity(userLoginEntity, false);
                    return(securehash);
                }
            }
            return(null);
        }
コード例 #9
0
        private LogBookDataModel GetLogBookWithDetails(int logNum, IDataAccessAdapter adapter, bool fetchWithDetails = false)
        {
            try
            {
                var toFetch = new LogBookEntity(logNum);
                var path    = new PrefetchPath2((int)EntityType.LogBookEntity);

                if (fetchWithDetails)
                {
                    path.Add(LogBookEntity.PrefetchPathLogDetails);
                }

                var fetchResult = adapter.FetchEntity(toFetch, path);

                if (!fetchResult)
                {
                    return(null);
                }

                var logBookModel = TransformLogBookEntityToModel(toFetch);

                logBookModel.LogDetailModel = new List <PackageModels.LogDetailModel>();

                foreach (var logDetail in toFetch.LogDetails)
                {
                    var logDetailModel = TransformLogDetailEntityToModel(logDetail);

                    logBookModel.LogDetailModel.Add(logDetailModel);
                }

                return(logBookModel);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #10
0
 protected void ExpectFetchEntity(bool entityExists, IEntity2 entityToFetch)
 {
     _entityToFetch = entityToFetch;
     Expect.Call(_dataAccessAdapter.FetchEntity(null)).IgnoreArguments().Return(entityExists)
     .Callback(new FetchEntityDelegate(FetchEntity));
 }