Example #1
0
        public IActionResult GetAccountsDropDown(string username, string password)
        {
            try
            {
                if (!repo.UserExist(username, password))
                {
                    logger.LogInformation($"Attemp failed to GetAccountsDropDown for the user:{username} with password :{password}");
                    return(BadRequest("Wrong username or password, please try again."));
                }
                else
                {
                    var Id_user = repo.GetUserID(username, password);

                    var accounts = repo.GetAccountsDropDown(Int16.Parse(Id_user));
                    if (accounts.Length > 0)
                    {
                        logger.LogInformation($"GetAccountsDropDown OK for the user:{username} with password :{password}");
                        return(Ok(accounts));
                    }
                    else
                    {
                        logger.LogInformation($"There aren't accounts on GetAccountsDropDown for the user:{username} with password :{password}");
                        return(BadRequest("There aren't accounts for the user."));
                    }
                }
            }
            catch (Exception ex)
            {
                logger.LogError($"GetAccountsDropDown error:_{ex}_");
                return(BadRequest("Error."));
            }
        }
Example #2
0
 public IActionResult GetTransactionHistory(string username, string password, string Id_Account, DateTime StartDate, DateTime EndDate)
 {
     try
     {
         if (!repo.UserExist(username, password))
         {
             logger.LogInformation($"Attemp failed to GetTransactionHistory with Id_Account:{Id_Account}, usr:{username}, pwd:{password},sd:{StartDate},ed:{EndDate}");
             return(BadRequest("Wrong username or password, please try again"));
         }
         else
         {
             var account = repo.GetTransactionHistory(Int16.Parse(Id_Account), StartDate, EndDate);
             if (account.Length > 0)
             {
                 logger.LogInformation($"GetTransactionHistory OK with Id_Account:{Id_Account}, usr:{username}, pwd:{password},sd:{StartDate},ed:{EndDate}");
                 return(Ok(account));
             }
             else
             {
                 logger.LogInformation($"There aren't records on GetTransactionHistory with Id_Account:{Id_Account}, usr:{username}, pwd:{password},sd:{StartDate},ed:{EndDate}");
                 return(BadRequest("There aren't accounts for the user."));
             }
         }
     }
     catch (Exception ex)
     {
         logger.LogError($"Error on GetTransactionHistory: _{ex}_");
         return(BadRequest("Error."));
     }
 }
Example #3
0
 public IActionResult ValidateUser(string username, string password)
 {
     try
     {
         if (!repo.UserExist(username, password))
         {
             logger.LogInformation($"Attemp to Log In for user:{username} with password :{password}");
             return(BadRequest("Wrong username or password , please try again."));
         }
         else
         {
             var user = repo.GetDataUser(username, password);
             logger.LogInformation($"Log In for user:{username} with password :{password}");
             return(Ok(user));
         }
     }
     catch (Exception ex)
     {
         logger.LogError($"Validate User method error:_{ex.Message}_");
         return(BadRequest("Error"));
     }
 }