Esempio n. 1
0
        public UserModel ChangePassword(ChangePasswordModel model)
        {
            ActivityLoggingComponent activityLog = new ActivityLoggingComponent();
            UserModel authModel = new UserModel();

            authModel.UserName = model.UserName;
            if (IsUserLoginFirstTime(authModel))
            {
                //first time login create new user with password
                UserModel userModel = new UserModel();
                userModel.UserName              = model.UserName;
                userModel.UserPassword          = model.UserPassword;
                userModel.SecretQuestionID      = model.PasswordQuestionID;
                userModel.SecretQuestionAnswer  = model.PasswordQuesAnswer;
                userModel.IsDeleted             = false;
                userModel.LoginFailAttemptCount = 0;
                userModel.CreatedBy             = model.CreatedBy;
                userModel.LastUpdatedBy         = model.LastUpdatedBy;
                return(CreateNewUser(userModel));
            }
            else
            {
                //change the user password
                using (AuthenticationRepository repo = new AuthenticationRepository())
                {
                    string         cryptoKey     = ConfigurationManager.AppSettings.Get("APSEncryptionKey").ToString();
                    ICryptoLibrary cryptLib      = new CryptoLibrary();
                    string         encrypted_pwd = cryptLib.Encrypt(model.UserPassword, cryptoKey);
                    model.UserPassword = encrypted_pwd;
                    var changePassowrd = repo.ChangeUserPassword(model);
                    if (changePassowrd.UserName != string.Empty)
                    {
                        UserActivityLogModel activityModel = new UserActivityLogModel
                        {
                            User_Name    = changePassowrd.UserName,
                            User_Act_Log = "Change password is successful. Activated User Name is: " + changePassowrd.UserName + ".",
                            CreatedBy    = changePassowrd.UserName,
                            CreatedTime  = DateTime.Now
                        };
                        activityLog.ActivityLog(activityModel);
                    }
                    return(changePassowrd);
                }
            }
        }
Esempio n. 2
0
        public UserModel AuthenticateUser(UserModel model)
        {
            string cryptoKey = ConfigurationManager.AppSettings.Get("APSEncryptionKey").ToString();

            if (!string.IsNullOrEmpty(cryptoKey))
            {
                ICryptoLibrary cryptLib = new CryptoLibrary();
                using (AuthenticationRepository repo = new AuthenticationRepository())
                {
                    UserModel userModel = new UserModel();
                    userModel.UserName = model.UserName;
                    userModel          = repo.GetUserDetails(userModel);
                    if (userModel != null)
                    {
                        string decrypted_pwd = cryptLib.Decrypt(userModel.UserPassword, cryptoKey);
                        if (model.UserPassword == decrypted_pwd)
                        {
                            //authentication success
                            userModel.IsAuthenticated = true;
                            return(userModel);
                        }
                        else
                        { //login attempt failed
                            userModel.IsAuthenticated       = false;
                            userModel.LoginFailAttemptCount = userModel.LoginFailAttemptCount + 1;
                            userModel.LastUpdatedBy         = userModel.UserName;
                            userModel = repo.UpdateLoginFailedCount(userModel);
                            return(userModel);
                        }
                    }
                    else
                    {
                        Log.Error("AuthenticateUser: No User info available in DB for this user: "******"AuthenticateUser: APSEncryptionKey is empty");
                return(null);
            }
        }
Esempio n. 3
0
        public UserModel CreateNewUser(UserModel model)
        {
            ActivityLoggingComponent activityLog = new ActivityLoggingComponent();
            string cryptoKey = ConfigurationManager.AppSettings.Get("APSEncryptionKey").ToString();

            if (!string.IsNullOrEmpty(cryptoKey))
            {
                ICryptoLibrary cryptLib      = new CryptoLibrary();
                string         encrypted_pwd = cryptLib.Encrypt(model.UserPassword, cryptoKey);
                model.UserPassword = encrypted_pwd;
                using (AuthenticationRepository repo = new AuthenticationRepository())
                {
                    var userCreation = repo.CreateNewUser(model);
                    if (userCreation.UserID > 0)
                    {
                        UserActivityLogModel activityModel = new UserActivityLogModel
                        {
                            User_Name    = userCreation.UserName,
                            User_Act_Log = "User creation successful. Newly created User Name is: " + userCreation.UserName + ".",
                            CreatedBy    = userCreation.CreatedBy,
                            CreatedTime  = DateTime.Now
                        };
                        activityLog.ActivityLog(activityModel);
                    }
                    return(userCreation);
                }
            }
            else
            {
                UserActivityLogModel activityModel = new UserActivityLogModel
                {
                    User_Name    = model.UserName,
                    User_Act_Log = "Error occurred! User creation was unsuccessful for : " + model.UserName + ".",
                    CreatedBy    = model.CreatedBy,
                    CreatedTime  = DateTime.Now
                };
                activityLog.ActivityLog(activityModel);
                throw new Exception();
            }
        }
Esempio n. 4
0
        public static int getSite()
        {
            saveSiteLog       = ConfigurationManager.AppSettings["saveSiteErrorLog"];
            Llog              = log4net.LogManager.GetLogger(saveSiteLog);
            log4netConfigFile = ConfigurationManager.AppSettings["Log4netConfig"];
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(log4netConfigFile));


            byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
            passwordBytes = SHA256.Create().ComputeHash(passwordBytes);
            byte[] bytesAlreadyEncrypted = null;
            try
            {
                bytesAlreadyEncrypted = File.ReadAllBytes(passworFile);
            }
            catch (Exception ex)
            {
                //Library.WriteErrorLog(logFileSaveSitePath, "failed to read the password file");
                //Library.WriteErrorLog(logFileSaveSitePath, ex.ToString());

                Llog.Info("failed to read the password file");
                Llog.Info(ex.ToString());

                string subject = "CCSVM SaveSites: Failed to read the password file";
                string body    = ex.ToString();
                Library.sendEmail(emailAddressFrom, adminEmailAddress, subject, body);
                return(-1);
            }
            byte[] bytesDecrypted      = new CryptoLibrary().AES_Decrypt(bytesAlreadyEncrypted, passwordBytes);
            string ccsVMServerPassword = Encoding.UTF8.GetString(bytesDecrypted);
            //Library.WriteErrorLog(logFileSaveSitePath, "userPassword:"******"Included IP List file path: " + includedFilePath);
            //Library.WriteErrorLog(logFileSaveSitePath, "Excluded IP List file path: " + excludedFilePath);

            Llog.Info("Included IP List file path: " + includedFilePath);
            Llog.Info("Excluded IP List file path: " + excludedFilePath);



            string month = "";

            if (today.Month < 10)
            {
                month = "0" + today.Month;
            }
            string day = "";

            if (today.Day < 10)
            {
                day = "0" + today.Day;
            }
            string includedFilePathNew = Path.GetDirectoryName(includedFilePath) + "\\" + Path.GetFileNameWithoutExtension(includedFilePath) + "-" + today.Year + month + day + Path.GetExtension(includedFilePath);
            string excludedFilePathNew = Path.GetDirectoryName(excludedFilePath) + "\\" + Path.GetFileNameWithoutExtension(excludedFilePath) + "-" + today.Year + month + day + Path.GetExtension(excludedFilePath);
            string includedFilePathTmp = includedFilePath + "-old";
            string excludedFilePathTmp = excludedFilePath + "-old";
            bool   getIncluded         = false;
            bool   getExcluded         = false;
            bool   processIncluded     = false;
            bool   processExcluded     = false;
            bool   otherError          = false; //error code -2

            //Library.WriteErrorLog(logFileSaveSitePath, "New Included IP List file path: " + includedFilePathNew);
            //Library.WriteErrorLog(logFileSaveSitePath, "Calling included ruby script: " + getSiteIncluded + " " + includedFilePathNew);

            Llog.Info("New Included IP List file path: " + includedFilePathNew);
            Llog.Info("Calling included ruby script: " + getSiteIncluded + " " + includedFilePathNew);

            string resultIncluded = CallRuby.runSiteScript(getSiteIncluded, ccsVMServerIP, ccsVMServerPort, ccsVMServerUser, ccsVMServerPassword, includedFilePathNew);

            Llog.Info("Calling included ruby script result: " + resultIncluded);

            //Library.WriteErrorLog(logFileSaveSitePath, "Calling included ruby script result: " + resultIncluded);

            if (resultIncluded.Contains("getsuccess"))
            {
                getIncluded = true;
                if (File.Exists(includedFilePathNew))
                {
                    //Library.WriteErrorLog(logFileSaveSitePath, "Calling ruby script successfully");
                    //Library.WriteErrorLog(logFileSaveSitePath, "Starting to replace the included csv file");

                    Llog.Info("Calling ruby script successfully");
                    Llog.Info("Starting to replace the included csv file");

                    FileStream streamIncluded = null;
                    while (true)
                    {
                        //remove old file
                        if (File.Exists(includedFilePathTmp))
                        {
                            //Library.WriteErrorLog(logFileSaveSitePath, "Clean up old file: " + includedFilePathTmp);
                            Llog.Info("Clean up old file: " + includedFilePathTmp);

                            try
                            {
                                File.Delete(includedFilePathTmp);
                            }
                            catch (Exception ex)
                            {
                                //Library.WriteErrorLog(logFileSaveSitePath, "Failed to remove old file: " + includedFilePathTmp);
                                //Library.WriteErrorLog(logFileSaveSitePath, ex.ToString());

                                Llog.Error("Failed to remove old file: " + includedFilePathTmp);
                                Llog.Error(ex.ToString());

                                string subject = "CCSVM SaveSites: Failed to remove old file";
                                string body    = includedFilePathTmp + ": " + ex.ToString();
                                Library.sendEmail(emailAddressFrom, adminEmailAddress, subject, body);
                                otherError = true;
                                return(-2);
                            }
                        }
                        //replace the file
                        if (File.Exists(includedFilePath))
                        {
                            try
                            {
                                streamIncluded = File.Open(includedFilePath, FileMode.Open, FileAccess.Read, FileShare.None);
                                streamIncluded.Close();
                                streamIncluded = null;
                                try
                                {
                                    File.Move(includedFilePath, includedFilePathTmp);
                                    //Library.WriteErrorLog(logFileSaveSitePath, "File successfully backup as: " + includedFilePathTmp);
                                    Llog.Info("File successfully backup as: " + includedFilePathTmp);
                                }
                                catch (Exception ex)
                                {
                                    //Library.WriteErrorLog(logFileSaveSitePath, "Failed to backup : " + includedFilePath);
                                    //Library.WriteErrorLog(logFileSaveSitePath, ex.ToString());

                                    Llog.Error("Failed to backup : " + includedFilePath);
                                    Llog.Error(ex.ToString());

                                    string subject = "CCSVM SaveSites: Failed to backup included csv file";
                                    string body    = includedFilePath + ": " + ex.ToString();
                                    Library.sendEmail(emailAddressFrom, adminEmailAddress, subject, body);
                                    otherError = true;
                                    return(-2);
                                }
                            }
                            catch (Exception)
                            {
                                //Library.WriteErrorLog(logFileSaveSitePath, "File in use, sleep for 5 seconds: " + includedFilePath);
                                Llog.Error("File in use, sleep for 5 seconds: " + includedFilePath);
                                System.Threading.Thread.Sleep(5000);
                                continue;
                            }
                            //replace with the new file
                            try
                            {
                                File.Move(includedFilePathNew, includedFilePath);
                            }
                            catch (Exception ex)
                            {
                                //Library.WriteErrorLog(logFileSaveSitePath, "Failed to move the new file: " + includedFilePathNew);
                                Llog.Error("Failed to move the new file: " + includedFilePathNew);
                                Llog.Error(ex.ToString());
                                //Library.WriteErrorLog(logFileSaveSitePath, ex.ToString());
                                string subject = "CCSVM SaveSites: Failed to move the new file";
                                string body    = includedFilePathNew + ": " + ex.ToString();
                                Library.sendEmail(emailAddressFrom, adminEmailAddress, subject, body);
                                otherError = true;
                                return(-2);
                            }
                            processIncluded = true;
                            break;
                        }
                        else
                        {
                            //Library.WriteErrorLog(logFileSaveSitePath, "File not exist: " + includedFilePath);
                            Llog.Info("File not exist: " + includedFilePath);

                            try
                            {
                                File.Move(includedFilePathNew, includedFilePath);
                            }
                            catch (Exception ex)
                            {
                                //Library.WriteErrorLog(logFileSaveSitePath, "Failed to move the new file: " + includedFilePathNew);
                                //Library.WriteErrorLog(logFileSaveSitePath, ex.ToString());
                                Llog.Error("Failed to move the new file: " + includedFilePathNew);
                                Llog.Error(ex.ToString());
                                string subject = "CCSVM SaveSites: Failed to move the new file";
                                string body    = includedFilePathNew + ": " + ex.ToString();
                                Library.sendEmail(emailAddressFrom, adminEmailAddress, subject, body);
                                return(-2);
                            }
                            break;
                        }
                    }
                }
                else
                {
                    Llog.Error("Calling included ruby script failed with unknown reason, check logs");
                    //Library.WriteErrorLog(logFileSaveSitePath, "Calling included ruby script failed with unknown reason, check logs");

                    //Library.WriteErrorLog(logFileSaveSitePath, resultIncluded);
                }
            }
            else
            {
                Llog.Error("Calling included ruby script failed with unknown reason, check logs");
                //Library.WriteErrorLog(logFileSaveSitePath, "Calling included ruby script failed with unknown reason, check logs");

                //Library.WriteErrorLog(logFileSaveSitePath, resultIncluded);
            }

            //processing for excluded ip list
            //Library.WriteErrorLog(logFileSaveSitePath, "New Excluded IP List file path: " + excludedFilePathNew);
            //Library.WriteErrorLog(logFileSaveSitePath, "Calling excluded ruby script: " + getSiteExcluded + " " + excludedFilePathNew);
            Llog.Info("New Excluded IP List file path: " + excludedFilePathNew);
            Llog.Info("Calling excluded ruby script: " + getSiteExcluded + " " + excludedFilePathNew);

            string resultExcluded = CallRuby.runSiteScript(getSiteExcluded, ccsVMServerIP, ccsVMServerPort, ccsVMServerUser, ccsVMServerPassword, excludedFilePathNew);

            //Library.WriteErrorLog(logFileSaveSitePath, "Calling excluded ruby script result: " + resultExcluded);
            Llog.Info("Calling excluded ruby script result: " + resultExcluded);
            if (resultExcluded.Contains("getsuccess"))
            {
                getExcluded = true;
                if (File.Exists(excludedFilePathNew))
                {
                    //Library.WriteErrorLog(logFileSaveSitePath, "Calling excluded ruby script successfully");
                    //Library.WriteErrorLog(logFileSaveSitePath, "Starting to replace the excluded csv file");
                    Llog.Info("Calling excluded ruby script successfully");
                    Llog.Info("Starting to replace the excluded csv file");

                    FileStream streamExcluded = null;
                    while (true)
                    {
                        //remove old file
                        if (File.Exists(excludedFilePathTmp))
                        {
                            //Library.WriteErrorLog(logFileSaveSitePath, "Clean up old file: " + excludedFilePathTmp);
                            Llog.Info("Clean up old file: " + excludedFilePathTmp);

                            try
                            {
                                File.Delete(excludedFilePathTmp);
                            }
                            catch (Exception ex)
                            {
                                //Library.WriteErrorLog(logFileSaveSitePath, "Failed to remove old file: " + excludedFilePathTmp);
                                //Library.WriteErrorLog(logFileSaveSitePath, ex.ToString());
                                Llog.Error("Failed to remove old file: " + excludedFilePathTmp);
                                Llog.Error(ex.ToString());

                                string subject = "CCSVM SaveSites: Failed to remove old file";
                                string body    = excludedFilePathTmp + ": " + ex.ToString();
                                Library.sendEmail(emailAddressFrom, adminEmailAddress, subject, body);
                                otherError = true;
                                return(-2);
                            }
                        }
                        //replace the file
                        if (File.Exists(excludedFilePath))
                        {
                            try
                            {
                                streamExcluded = File.Open(excludedFilePath, FileMode.Open, FileAccess.Read, FileShare.None);
                                streamExcluded.Close();
                                streamExcluded = null;
                                try
                                {
                                    File.Move(excludedFilePath, excludedFilePathTmp);
                                    Llog.Info("File successfully backup as: " + excludedFilePathTmp);
                                    //Library.WriteErrorLog(logFileSaveSitePath, "File successfully backup as: " + excludedFilePathTmp);
                                }
                                catch (Exception ex)
                                {
                                    //Library.WriteErrorLog(logFileSaveSitePath, "Failed to backup : " + excludedFilePath);
                                    //Library.WriteErrorLog(logFileSaveSitePath, ex.ToString());

                                    Llog.Error("Failed to backup : " + excludedFilePath);
                                    Llog.Error(ex.ToString());

                                    string subject = "CCSVM SaveSites: Failed to backup file";
                                    string body    = excludedFilePath + ": " + ex.ToString();
                                    Library.sendEmail(emailAddressFrom, adminEmailAddress, subject, body);
                                    otherError = true;
                                    return(-2);
                                }
                            }
                            catch (Exception)
                            {
                                //Library.WriteErrorLog(logFileSaveSitePath, "File in use, sleep for 5 seconds: " + excludedFilePath);
                                Llog.Info("File in use, sleep for 5 seconds: " + excludedFilePath);

                                System.Threading.Thread.Sleep(5000);
                                continue;
                            }

                            //replace with the new file
                            try
                            {
                                File.Move(excludedFilePathNew, excludedFilePath);
                            }
                            catch (Exception ex)
                            {
                                //Library.WriteErrorLog(logFileSaveSitePath, "Failed to move the new file: " + excludedFilePathNew);
                                //Library.WriteErrorLog(logFileSaveSitePath, ex.ToString());
                                Llog.Error("Failed to move the new file: " + excludedFilePathNew);
                                Llog.Error(ex.ToString());

                                string subject = "CCSVM SaveSites: Failed to move the new file";
                                string body    = excludedFilePathNew + ": " + ex.ToString();
                                Library.sendEmail(emailAddressFrom, adminEmailAddress, subject, body);
                                otherError = true;
                                return(-2);
                            }
                            processExcluded = true;
                            break;
                        }
                        else
                        {
                            //Library.WriteErrorLog(logFileSaveSitePath, "File not exist: " + excludedFilePath);
                            Llog.Error("File not exist: " + excludedFilePath);


                            try
                            {
                                File.Move(excludedFilePathNew, excludedFilePath);
                            }
                            catch (Exception ex)
                            {
                                //Library.WriteErrorLog(logFileSaveSitePath, "Failed to move the new file: " + excludedFilePathNew);
                                //Library.WriteErrorLog(logFileSaveSitePath, ex.ToString());
                                Llog.Error("Failed to move the new file: " + excludedFilePathNew);
                                Llog.Error(ex.ToString());
                                string subject = "CCSVM SaveSites: Failed to move the new file";
                                string body    = excludedFilePathNew + ": " + ex.ToString();
                                Library.sendEmail(emailAddressFrom, adminEmailAddress, subject, body);
                                return(-2);
                            }
                            break;
                        }
                    }
                }
                else
                {
                    //Library.WriteErrorLog(logFileSaveSitePath, "Calling excluded ruby script failed with unknown reason, check logs");
                    Llog.Error("Calling excluded ruby script failed with unknown reason, check logs");
                }
            }
            else
            {
                //Library.WriteErrorLog(logFileSaveSitePath, "Calling excluded ruby script failed with unknown reason, check logs");
                Llog.Error("Calling excluded ruby script failed with unknown reason, check logs");
            }

            //Library.WriteErrorLog(logFileSaveSitePath, "Finish running");
            Llog.Info("Finish running");

            if (otherError)
            {
                return(-2);
            }
            else
            {
                if (getIncluded & getExcluded)
                {
                    if (processIncluded & processExcluded)
                    {
                        return(2);
                    }
                    else
                    {
                        return(1);
                    }
                }
                else
                {
                    return(-1);
                }
            }
        }
Esempio n. 5
0
        public ForgetPasswordModel ForgetPassword(ForgetPasswordModel model)
        {
            ActivityLoggingComponent activityLog = new ActivityLoggingComponent();
            string cryptoKey    = ConfigurationManager.AppSettings.Get("APSEncryptionKey").ToString();
            string tempPassword = ConfigurationManager.AppSettings.Get("ResetTempPassword").ToString();

            if (!string.IsNullOrEmpty(cryptoKey))
            {
                ICryptoLibrary cryptLib = new CryptoLibrary();
                using (AuthenticationRepository repo = new AuthenticationRepository())
                {
                    SendEmailRequest emailRequest = new SendEmailRequest();
                    UserModel        userModel    = new UserModel();
                    userModel.UserName = model.UserName;
                    userModel          = repo.GetUserDetails(userModel);
                    if (userModel != null)
                    {
                        if (userModel.PasswordChangeFailAttemptCount <= 3)
                        {
                            if (model.PasswordQuestionID == userModel.SecretQuestionID && model.PasswordQuesAnswer == userModel.SecretQuestionAnswer)
                            {
                                // Reset the password
                                string encrypted_pwd = cryptLib.Encrypt(tempPassword, cryptoKey);
                                model.UserPassword = encrypted_pwd;
                                model.PasswordChangeFailAttempt = 0;
                                model.IsSuccess     = true;
                                model.LastUpdatedBy = model.UserName;
                                var resetModel = repo.ResetPassword(model);
                                //Then send email or sms the password to the user
                                if (!string.IsNullOrEmpty(model.Email))
                                {
                                    BuildAndSendEmailRequest(emailRequest, model.Email, "APS - Reset Password", "Your password has been changed. New password is: " + tempPassword + "Please Change the password after login using the temporary password. Thank You.");
                                }
                                else if (!string.IsNullOrEmpty(model.MobileNumber))
                                {
                                    // send SMS
                                }
                                if (!string.IsNullOrEmpty(model.UserName))
                                {
                                    UserActivityLogModel activityModel = new UserActivityLogModel
                                    {
                                        User_Name    = model.UserName,
                                        User_Act_Log = "Reset password is successful. Activated User Name is: " + model.UserName + ".",
                                        CreatedBy    = model.UserName,
                                        CreatedTime  = DateTime.Now
                                    };
                                    activityLog.ActivityLog(activityModel);
                                }
                                return(resetModel);
                            }
                            else
                            {
                                //Update the PasswordChagneFailAttempt count
                                if (userModel.PasswordChangeFailAttemptCount != 0)
                                {
                                    model.PasswordChangeFailAttempt = userModel.PasswordChangeFailAttemptCount + 1;
                                }
                                else
                                {
                                    model.PasswordChangeFailAttempt = 1;
                                }
                                model.IsSuccess     = false;
                                model.LastUpdatedBy = model.UserName;
                                return(repo.UpdateChangePasswordFailedCount(model));
                            }
                        }
                        else
                        {
                            if (userModel.DOBFailAttemptCount <= 3)
                            {
                                UserInfoModel userInfoModel = new UserInfoModel();
                                userInfoModel.UserName = model.UserName;
                                userInfoModel          = repo.GetUserInfoDetails(userInfoModel);
                                if (userInfoModel != null)
                                {
                                    string dateOfBirth = userInfoModel.UserDateOfBirth;
                                    if (dateOfBirth == model.DateOfBirth)
                                    {
                                        string encrypted_pwd = cryptLib.Encrypt(tempPassword, cryptoKey);
                                        model.UserPassword           = encrypted_pwd;
                                        model.DateOfBirthFailAttempt = 0;
                                        model.IsSuccess                 = true;
                                        model.LastUpdatedBy             = model.UserName;
                                        model.PasswordChangeFailAttempt = userModel.PasswordChangeFailAttemptCount;
                                        var resetModel = repo.ResetPassword(model);
                                        //Then send email or sms the password to the user
                                        if (!string.IsNullOrEmpty(model.Email))
                                        {
                                            BuildAndSendEmailRequest(emailRequest, model.Email, "APS - Reset Password", "Your password has been changed. New password is: " + tempPassword + " Please Change the password after login using the temporary password. Thank You.");
                                        }
                                        else if (!string.IsNullOrEmpty(model.MobileNumber))
                                        {
                                            // send SMS
                                        }
                                        if (!string.IsNullOrEmpty(model.UserName))
                                        {
                                            UserActivityLogModel activityModel = new UserActivityLogModel
                                            {
                                                User_Name    = model.UserName,
                                                User_Act_Log = "Reset password is successful using Date of birth option. Activated User Name is: " + model.UserName + ".",
                                                CreatedBy    = model.UserName,
                                                CreatedTime  = DateTime.Now
                                            };
                                            activityLog.ActivityLog(activityModel);
                                        }
                                        return(resetModel);
                                    }
                                    else
                                    {
                                        //Update the PasswordChagneFailAttempt count
                                        if (userModel.DOBFailAttemptCount != 0)
                                        {
                                            model.DateOfBirthFailAttempt = userModel.DOBFailAttemptCount + 1;
                                        }
                                        else
                                        {
                                            model.DateOfBirthFailAttempt = 1;
                                        }
                                        model.IsSuccess                 = false;
                                        model.LastUpdatedBy             = model.UserName;
                                        model.PasswordChangeFailAttempt = userModel.PasswordChangeFailAttemptCount;
                                        return(repo.UpdateDateOfBirthFailCount(model));
                                    }
                                }
                                else
                                {
                                    model.IsSuccess = false;
                                    return(model);
                                }
                            }
                            else
                            {
                                //Contact case officer - Exceeded all the possible way
                                model.IsSuccess = false;
                                return(model);
                            }
                        }
                    }
                    model.IsSuccess = false;
                    return(model);
                }
            }
            else
            {
                throw new Exception();
            }
        }