public static ResendOtpResponse ResendOtp(ResendOtpRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            ResendOtpResponse response = new ResendOtpResponse();

            response.otp_details = new OTPDetailsDto();
            SuperAdmin suerUser = null;

            try
            {
                using (SuperUserDao sUserDao = new SuperUserDao())
                {
                    suerUser = sUserDao.FindByMobileNumber(request.mobile_number);
                }
                if (suerUser == null)
                {
                    MakeNouserResponse(response);
                    return(response);
                }

                OTPServices.ResendOTP(response, suerUser.MobileNum, suerUser.SAdminID, "S");
                response.code                 = 0;
                response.has_resource         = 1;
                response.message              = MessagesSource.GetMessage("otp.resent");
                response.otp_details.send_otp = 1;
                return(response);
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
        public static ForgotPasswordResponse ForgotPassword(ForgotPasswordRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            ForgotPasswordResponse response = new ForgotPasswordResponse();

            //string newPassword = TokenGenerator.GenerateResetPassword();
            try
            {
                using (SuperUserDao dao = new SuperUserDao())
                {
                    SuperAdmin superAdmin = dao.FindByMobileNumber(request.mobile_number);
                    if (superAdmin == null)
                    {
                        MakeNouserResponse(response);
                        return(response);
                    }
                    OTPServices.SendOTPForForgotPassword(response, request.mobile_number, superAdmin.SAdminID, "S");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
        public static LoginResponse Login(LoginRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            LoginResponse response     = new LoginResponse();
            SuperAdmin    superuser    = null;
            string        hashPassword = TokenGenerator.GetHashedPassword(request.password, 49);

            try
            {
                using (SuperUserDao dao = new SuperUserDao())
                {
                    superuser = dao.FindByMobileNumber(request.mobile_number);
                    if (superuser == null)
                    {
                        MakeNouserResponse(response);
                        return(response);
                    }
                    if (hashPassword == superuser.Password)
                    {
                        response.code         = 1;
                        response.has_resource = 0;
                        //admin. = request.app_id;
                        superuser.AppToken  = request.push_token;
                        superuser.AppID     = request.app_id;
                        superuser.LastLogin = DateTime.Now;
                        string authToken = TokenGenerator.GenerateToken(superuser.FullName, superuser.Password, request.mobile_number);
                        superuser.AccToken = authToken;
                        dao.Update(superuser);
                        response.code = 0;
                        SuperUserLoginDto dto = new SuperUserLoginDto();
                        SuperUserHelper.CopyFromEntity(dto, superuser);

                        SuperUserLoginDetailsDto dtoDetails = new SuperUserLoginDetailsDto();
                        SuperUserHelper.CopyFromEntity(dtoDetails, superuser);


                        response.user_login         = dto;
                        response.super_user_details = dtoDetails;
                        response.has_resource       = 1;
                        response.code    = 0;
                        response.message = MessagesSource.GetMessage("login.ok");
                        return(response);
                    }
                    else
                    {
                        response.code         = 1;
                        response.has_resource = 0;
                        response.message      = MessagesSource.GetMessage("login.fail");
                    }
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
            }
            return(response);
        }
        public static SuperAdmin GetAuthUserbyMobileNumber(string mobilenumber)
        {
            ResponseDto response  = new ResponseDto();
            SuperAdmin  superuser = null;

            using (SuperUserDao dao = new SuperUserDao())
            {
                superuser = dao.FindByMobileNumber(mobilenumber);
                if (superuser != null)
                {
                    return(superuser);
                }
                if (response != null)
                {
                    response.code         = 1;
                    response.has_resource = 0;
                    response.message      = MessagesSource.GetMessage("invalid.superuser");
                }
                return(null);
            }
        }
        //public static ResendOtpResponse ResendOtp(ResendOtpRequest request)
        //{
        //    ResendOtpResponse response = new ResendOtpResponse();
        //    response.otp_details = new OtpDetailsDto();
        //    SuperAdmin superuser = null;
        //    try
        //    {
        //        if (!SuperUserServices.CheckSuperUser(request.mobile_number))
        //        {
        //            response.message = MessagesSource.GetMessage("no.super.user");
        //            return response;
        //        }
        //        using (SuperUserDao userDao = new SuperUserDao())
        //        {

        //            superuser = userDao.FindByMobileNumber(request.mobile_number);
        //        }
        //        OTPServices.ResendOTP(superuser.SAdminID, request.mobile_number, "A");
        //        response.code = 0;
        //        response.has_resource = 1;
        //        response.message = MessagesSource.GetMessage("otp.resent");
        //        response.otp_details.send_otp = 1;
        //        return response;
        //    }
        //    catch (Exception ex)
        //    {
        //        response.MakeExceptionResponse(ex);
        //        return response;
        //    }
        //}
        public static ResponseDto ResetPassword(ResetPasswordRequest request)
        {
            ResponseDto response            = new ResponseDto();
            SuperAdmin  superuser           = null;
            string      newPasswordHash     = TokenGenerator.GetHashedPassword(request.new_password, 49);
            string      confirmPasswordHash = TokenGenerator.GetHashedPassword(request.confirm_password, 49);

            try
            {
                if (!SuperUserServices.CheckSuperUser(request.mobile_number))
                {
                    response.message = MessagesSource.GetMessage("no.super.user");
                    return(response);
                }
                using (SuperUserDao dao = new SuperUserDao())
                {
                    superuser = dao.FindByMobileNumber(request.mobile_number);
                    //agentBoss = dao.FindById(request.user_id);
                    if (newPasswordHash == confirmPasswordHash)
                    {
                        superuser.Password = TokenGenerator.GetHashedPassword(request.new_password, 49);
                        dao.Update(superuser);
                        response.code         = 0;
                        response.has_resource = 0;
                        response.message      = MessagesSource.GetMessage("passwd.reset");
                        return(response);
                    }
                }
                response.code         = 1;
                response.has_resource = 0;
                response.message      = MessagesSource.GetMessage("exception");
                return(response);
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }