public UserData ValidateLogin(string username, string password) { UserData data = new UserData(); try { UserInfo info = new UserInfo(); info = RetriveUserInformation(username, password); ResultData result = new ResultData(); if (info != null) { result = UpdateLoginHistory("Login Successfully", info.EmployeeID); if (result != null) { if (result.ResultCode == 0) { data.UserInformation = info; data.ResultCode = ResultCodes.SUCCESSFUL_TRANSACTION; data.ResultMessage = ResultCodes.toDesctiption(ResultCodes.SUCCESSFUL_TRANSACTION); } else { data.ResultCode = ResultCodes.UNSUCCESSFUL_TRANSACTION; data.ResultMessage = ResultCodes.toDesctiption(ResultCodes.UNSUCCESSFUL_TRANSACTION); } } else { data.ResultCode = ResultCodes.UNSUCCESSFUL_TRANSACTION; data.ResultMessage = ResultCodes.toDesctiption(ResultCodes.UNSUCCESSFUL_TRANSACTION); } } else { data.ResultCode = ResultCodes.UNSUCCESSFUL_TRANSACTION; data.ResultMessage = ResultCodes.toDesctiption(ResultCodes.UNSUCCESSFUL_TRANSACTION); } } catch (Exception e) { data = new UserData(); data.ResultCode = ResultCodes.UNSUCCESSFUL_TRANSACTION; data.ResultMessage = ResultCodes.toDesctiption(ResultCodes.UNSUCCESSFUL_TRANSACTION); } return data; }
private ResultData CreateUpdateLoginHistory(IDataReader reader) { ResultData r = new ResultData() { ResultCode = DataAccessUtility.Retrieve<int>(reader, VJColumnName.CONST_RESULT_CODE), ResultMessage = DataAccessUtility.Retrieve<string>(reader, VJColumnName.CONST_RESULT_MESSAGE) }; return r; }