示例#1
0
        /// <summary>
        /// Method updates password with newer one.
        /// </summary>
        /// <param name="userId">User id</param>
        /// <param name="newPassword">New passowrd</param>
        /// <param name="oldPassword">Old passowrd</param>
        /// <param name="userRepository">User repository</param>
        /// <returns>1 or 0</returns>
        public int ChangePassowrd(int userId, string newPassword, string oldPassword, IRepository <user> userRepository)
        {
            IQueryable <user> userList = userRepository.FindBy(UtilityAdapter.BuildUserExistPredicate(userId));

            //Updating new changes
            if (userList.Any())
            {
                user userData = userList.First();
                if (userData.Password == oldPassword)
                {
                    userData.Password     = newPassword;
                    userData.DateModified = DateTime.Now;
                    return(userRepository.Update(userData));
                }
                return(Constants.MinusOne);
            }
            return(Constants.Zero);
        }
示例#2
0
        /// <summary>
        /// Method updates user details.
        /// </summary>
        /// <param name="userDetailEntity">User Detail Entity</param>
        /// <param name="userRepository">User repository</param>
        /// <returns>1 or -1</returns>
        public int UpdateUserDetails(UserDetailEntity userDetailEntity, IRepository <user> userRepository)
        {
            int result;
            IQueryable <user> userList = userRepository.FindBy(UtilityAdapter.BuildUserExistPredicate(userDetailEntity.UserId));
            user userDetailData        = userList.First();

            //No records for given userid
            if (userDetailData == null)
            {
                return(Constants.MinusOne);
            }
            if (userDetailData.userdetail != null)
            {
                userDetailData.userdetail.AnnualIncome     = userDetailEntity.AnnualIncome;
                userDetailData.userdetail.DateModified     = DateTime.Now;
                userDetailData.userdetail.EducationLevel   = userDetailEntity.EducationLevel;
                userDetailData.userdetail.EmploymentStatus = userDetailEntity.EmploymentStatus;
                userDetailData.userdetail.NetWorth         = userDetailEntity.NetWorth;
                userDetailData.userdetail.SourceOfFunds    = userDetailEntity.SourceOfFunds;
                result = userRepository.Update(userDetailData);
            }
            else
            {
                // Inserting new record in UserDetails table
                userDetailData.userdetail = new userdetail
                {
                    ActiveIndicator  = Constants.DbActive,
                    AnnualIncome     = userDetailEntity.AnnualIncome,
                    DateCreated      = DateTime.Now,
                    EducationLevel   = userDetailEntity.EducationLevel,
                    EmploymentStatus = userDetailEntity.EmploymentStatus,
                    NetWorth         = userDetailEntity.NetWorth,
                    SourceOfFunds    = userDetailEntity.SourceOfFunds,
                };
                // Updating Users table with recent UserDetailID
                result = userRepository.Update(userDetailData);
            }
            return(result);
        }
示例#3
0
        /// <summary>
        /// Method updates user profile details.
        /// </summary>
        /// <param name="userEntity">User entity</param>
        /// <param name="userRepository">User repository</param>
        /// <returns>true or false</returns>
        public bool UpdateUserProfile(UserEntity userEntity, IRepository <user> userRepository)
        {
            IQueryable <user> userList = userRepository.FindBy(UtilityAdapter.BuildUserExistPredicate(userEntity.UserId));

            //Updating new changes
            if (userList.Any())
            {
                user userData = userList.First();
                userData.Adddress     = userEntity.Adddress;
                userData.City         = userEntity.City;
                userData.ContactNo    = userEntity.ContactNo;
                userData.DateOfBirth  = userEntity.DateOfBirth;
                userData.Email        = userEntity.Email;
                userData.FullName     = userEntity.FullName;
                userData.Gender       = userEntity.Gender;
                userData.PassportNo   = userEntity.PassportNo;
                userData.PostalCode   = userEntity.PostalCode;
                userData.State        = userEntity.State;
                userData.CountryId    = userEntity.Country != null ? userEntity.Country.CountryId : userData.CountryId;
                userData.DateModified = DateTime.Now;
                return(userRepository.Update(userData) > 0);
            }
            return(false);
        }
示例#4
0
        /// <summary>
        /// Method helps to get user profile.
        /// </summary>
        /// <param name="userId">User id</param>
        /// <param name="userRepository">User repository</param>
        /// <returns>User entity</returns>
        public UserEntity GetUserProfile(int userId, IRepository <user> userRepository)
        {
            UserEntity userEntity = null;
            //Query data from db
            IQueryable <user> dbUsers = userRepository.FindBy(UtilityAdapter.BuildUserExistPredicate(userId));

            //Map db data into entities
            if (dbUsers.Any())
            {
                user tempUser = dbUsers.First();
                userEntity = new UserEntity
                {
                    UserId          = tempUser.UserID,
                    ActiveIndicator = tempUser.ActiveIndicator,
                    Gender          = tempUser.Gender,
                    PassportNo      = tempUser.PassportNo,
                    State           = tempUser.State,
                    City            = tempUser.City,
                    ContactNo       = tempUser.ContactNo,
                    PostalCode      = tempUser.PostalCode,
                    Adddress        = tempUser.Adddress,
                    DateOfBirth     = tempUser.DateOfBirth,
                    Email           = tempUser.Email,
                    FullName        = tempUser.FullName,
                };
                if (tempUser.country != null)
                {
                    userEntity.Country = new CountryEntity
                    {
                        CountryId = tempUser.country.CountryID,
                        Name      = tempUser.country.Name
                    };
                }
            }
            return(userEntity);
        }