Ejemplo n.º 1
0
        public IActionResult ValidateOTPLogin([FromBody] OTPValidatorRequest request)
        {
            OTPValidatorResponse response = new OTPValidatorResponse();

            if (CurrentAccount == null)
            {
                throw new NotImplementedException();
            }
            OTPRep oTPRep = new OTPRep(Context);
            bool   access = oTPRep.ValidateOTP(request.Otp, CurrentAccount.LastOtpid);

            if (access == true)
            {
                response.Status         = 1;
                response.CurrentBalance = 200.23;
                response.AdditionalInfo = "Login successfully with otp " + request.Otp + "\n"
                                          + "Basic Info: " + request.BasicInfo.ToString();
            }
            else
            {
                //Not Emplemented Error Code Yet
                response.Status         = 2;
                response.CurrentBalance = 200.23;
                response.AdditionalInfo = "Login Failed with otp " + request.Otp + "\n"
                                          + "Basic Info: " + request.BasicInfo.ToString();
            }
            return(Ok(response));
        }
Ejemplo n.º 2
0
        public IActionResult ValidateOTPLogin([FromBody] OTPValidatorRequest request)
        {
            if (!request.ValidateObject())
            {
                try
                {
                    ExceptionHandeling.FireError((int)ErrorCode.General_Error, (int)GeneralError.Nullable_Request, Constants.Constants.GeneralErrorDic[GeneralError.Nullable_Request]);
                }
                catch (CodeLabException codelabExp)
                {
                    return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
                }
            }
            OTPValidatorResponse response   = new OTPValidatorResponse();
            AccountRep           accountRep = new AccountRep(Context);
            Account CurrentAccount          = accountRep.GetByMSDIN(request.BasicInfo.MobileNumberInfo.Number);

            if (CurrentAccount == null)
            {
                try
                {
                    ExceptionHandeling.FireError((int)ErrorCode.Wrong_Input_Error, (int)WrongInputError.Wrong_Wallet_Number, Constants.Constants.WrongInputDic[WrongInputError.Wrong_Wallet_Number]);
                }
                catch (CodeLabException codelabExp)
                {
                    return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
                }
            }
            OTPRep oTPRep = new OTPRep(Context);
            bool   access = oTPRep.ValidateOTP(request.Otp, CurrentAccount.LastOtpid);

            if (access == true)
            {
                response.Status         = 1;
                response.CurrentBalance = (double)CurrentAccount.Balance;
                response.AdditionalInfo = "Login successfully with otp " + request.Otp + "\n"
                                          + "Basic Info: " + request.BasicInfo.ToString();
            }
            else
            {
                try
                {
                    ExceptionHandeling.FireError((int)ErrorCode.Wrong_Input_Error, (int)WrongInputError.Wrong_Otp, Constants.Constants.WrongInputDic[WrongInputError.Wrong_Otp]);
                }
                catch (CodeLabException codelabExp)
                {
                    return(ExceptionHandeling.GenerateErrorResponse(codelabExp));
                }
            }
            return(Ok(response));
        }