diff --git a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs
index 7560612..b8eef73 100644
--- a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs
+++ b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs
@@ -30,7 +30,7 @@ namespace AIAHTML5.API.Models
conn.Open();
}
- protected static DataSet GetSQLData(string commandText, bool isSp)
+ protected static DataSet GetDataFromStoredProcedure(string commandText)
{
ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
logger.Debug(" Inside GetSQLData for command text = " + commandText);
@@ -38,15 +38,8 @@ namespace AIAHTML5.API.Models
try
{
conn = new SqlConnection(dbConnectionString);
- if (isSp)
- {
- cmd = new SqlCommand(commandText, conn);
- cmd.CommandType = CommandType.StoredProcedure;
- }
- else
- {
- cmd = new SqlCommand(commandText, conn);
- }
+ cmd = new SqlCommand(commandText, conn);
+ cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
ds = new DataSet();
@@ -59,210 +52,204 @@ namespace AIAHTML5.API.Models
return ds;
}
- public ArrayList GetUserModules()
+ internal ArrayList GetAllModules()
{
+ ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
+ logger.Debug(" Inside GetAllModules");
+
ArrayList arrUserModules = new ArrayList();
- Hashtable userModuleHash = null;
- userModuleHash = new Hashtable();
- string sp = "GetAllModuleStatusWithSlug";
+ try
+ {
+ Hashtable userModuleHash = new Hashtable();
+
+ string sp = DBConstants.GET_ALL_MODULES;
- DataSet ds = DBModel.GetSQLData(sp, true);
- DataTable dt = ds.Tables[0];
+ DataSet ds = DBModel.GetDataFromStoredProcedure(sp);
- foreach (DataRow drActType in dt.Rows)
+ if (ds.Tables.Count > 0)
+ {
+ DataTable dt = ds.Tables[0];
+
+ foreach (DataRow drModule in dt.Rows)
+ {
+ userModuleHash = new Hashtable();
+ userModuleHash.Add(AIAConstants.KEY_NAME, drModule["Name"]);
+ userModuleHash.Add(AIAConstants.KEY_SLUG, drModule["Slug"]);
+ arrUserModules.Add(userModuleHash);
+ }
+ }
+ }
+ catch (SqlException ex)
{
- userModuleHash = new Hashtable();
- userModuleHash.Add(AIAConstants.KEY_NAME, drActType["Name"]);
- userModuleHash.Add(AIAConstants.KEY_SLUG, drActType["Slug"]);
- arrUserModules.Add(userModuleHash);
+ logger.Fatal("Exception in GetAllModules , Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
}
return arrUserModules;
}
- public static dynamic GetUserDetailsByLoginIdAndPassword(string loginId, string password)
+ internal static dynamic GetUserDetailsByLoginId(string loginId)
{
+ ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
+ logger.Debug(" Inside GetUserDetailsByLoginId for LoginId = " + loginId);
+
User objUser = new User();
DBModel objModel = new DBModel();
- conn = new SqlConnection(dbConnectionString);
- cmd = new SqlCommand();
- SqlDataAdapter da = new SqlDataAdapter();
- SqlParameter param;
- DataSet ds = new DataSet();
+ try
+ {
+ conn = new SqlConnection(dbConnectionString);
+ cmd = new SqlCommand();
+ SqlDataAdapter da = new SqlDataAdapter();
+ SqlParameter param;
+ DataSet ds = new DataSet();
- cmd.Connection = conn;
- cmd.CommandText = "GetUserDetailsByLoginId";
- cmd.CommandType = CommandType.StoredProcedure;
+ cmd.Connection = conn;
+ cmd.CommandText = DBConstants.GET_USER_DELAILS_BY_LOGIN_ID;
+ cmd.CommandType = CommandType.StoredProcedure;
- param = new SqlParameter("@sLoginId", loginId);
- param.Direction = ParameterDirection.Input;
- param.DbType = DbType.String;
- cmd.Parameters.Add(param);
+ param = new SqlParameter("@sLoginId", loginId);
+ param.Direction = ParameterDirection.Input;
+ param.DbType = DbType.String;
+ cmd.Parameters.Add(param);
- da.SelectCommand = cmd;
- DataTable dt = new DataTable();
- da.Fill(dt);
+ da.SelectCommand = cmd;
+ DataTable dt = new DataTable();
+ da.Fill(dt);
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
+ if (dt.Rows.Count > 0)
{
- foreach (DataColumn dc in dt.Columns)
+ foreach (DataRow dr in dt.Rows)
{
- if (dc.ColumnName == "Id")
- objUser.Id = Convert.ToInt32(dr[dc]);
- if (dc.ColumnName == "FirstName")
- objUser.FirstName = dr[dc].ToString();
- if (dc.ColumnName == "LastName")
- objUser.LastName = dr[dc].ToString();
- if (dc.ColumnName == "EmailId")
- objUser.EmailId = dr[dc].ToString();
- if (dc.ColumnName == "LoginId")
- objUser.LoginId = dr[dc].ToString();
- if (dc.ColumnName == "Password")
- objUser.Password = dr[dc].ToString();
- if (dc.ColumnName == "SecurityQuestionId")
- {
- int tempVal;
- objUser.SecurityQuestionId = Int32.TryParse(dr[dc].ToString(), out tempVal) ? tempVal : (int?)null;
- }
- if (dc.ColumnName == "SecurityAnswer")
- objUser.SecurityAnswer = dr[dc].ToString();
- if (dc.ColumnName == "CreatorId")
- {
- int tempVal;
- objUser.CreatorId = Int32.TryParse(dr[dc].ToString(), out tempVal) ? tempVal : (int?)null;
- }
- if (dc.ColumnName == "CreationDate")
- objUser.CreationDate = Convert.ToDateTime(dr[dc]);
- if (dc.ColumnName == "DeactivationDate")
- {
- DateTime? date;
- if (dr[dc] == DBNull.Value)
- date = null;
- else
- date = (DateTime)dr[dc];
-
- objUser.DeactivationDate = date;
- }
- if (dc.ColumnName == "ModifierId")
- {
- int tempVal;
- objUser.ModifierId = Int32.TryParse(dr[dc].ToString(), out tempVal) ? tempVal : (int?)null;
- }
- if (dc.ColumnName == "ModifiedDate")
- {
- DateTime? date;
- if (dr[dc] == DBNull.Value)
- date = null;
- else
- date = (DateTime)dr[dc];
-
- objUser.ModifiedDate = date;
- }
- if (dc.ColumnName == "UserTypeId")
- {
- objUser.UserTypeId = Convert.ToInt32(dr[dc]);
- objUser.UserType = objModel.GetUserTypeStringById(Convert.ToInt32(dr[dc]));
- }
- if (dc.ColumnName == "IsActive")
- objUser.IsActive = Convert.ToBoolean(dr[dc]);
-
+ int tempVal;
+ DateTime date;
+
+ objUser.Id = Convert.ToInt32(dr["Id"]);
+ objUser.FirstName = dr["FirstName"].ToString();
+ objUser.LastName = dr["LastName"].ToString();
+ objUser.EmailId = dr["EmailId"].ToString();
+ objUser.LoginId = dr["LoginId"].ToString();
+ objUser.Password = dr["Password"].ToString();
+ objUser.SecurityQuestionId =Int32.TryParse(dr["SecurityQuestionId"].ToString(), out tempVal) ? tempVal : (int?)null;
+ objUser.SecurityAnswer = dr["SecurityAnswer"].ToString(); ;
+ objUser.CreatorId = Int32.TryParse(dr["CreatorId"].ToString(), out tempVal) ? tempVal : (int?)null;
+ objUser.CreationDate = Convert.ToDateTime(dr["CreationDate"]);
+ objUser.DeactivationDate = DateTime.TryParse(dr["DeactivationDate"].ToString(), out date) ? date : (DateTime?)null;
+ objUser.ModifierId = Int32.TryParse(dr["ModifierId"].ToString(), out tempVal) ? tempVal : (int?)null;
+ objUser.ModifiedDate = DateTime.TryParse(dr["ModifiedDate"].ToString(), out date) ? date : (DateTime?)null;
+ objUser.UserTypeId = Convert.ToInt32(dr["UserTypeId"]);
+ objUser.UserType = objModel.GetUserTypeStringById(Convert.ToInt32(dr["UserTypeId"]));
+ objUser.IsActive = Convert.ToBoolean(dr["IsActive"]);
}
}
+ else
+ {
+ objUser = null;
+ }
}
- else
+ catch (SqlException ex)
{
- objUser = null;
+ logger.Fatal("Exception in GetUserDetailsByLoginId for LoginId: " + loginId + ", Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
}
return objUser;
}
- public Hashtable GetUserLicenseDetailByUserId(int userId)
+ internal Hashtable GetLicenseDetailByUserId(int userId)
{
+ ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
+ logger.Debug(" Inside GetUserLicenseDetailByUserId for UserId = " + userId);
+
Hashtable hash = new Hashtable();
- conn = new SqlConnection(dbConnectionString);
- cmd = new SqlCommand();
- SqlDataAdapter adapter;
- SqlParameter param;
- DataSet ds = new DataSet();
+ try
+ {
+ conn = new SqlConnection(dbConnectionString);
+ cmd = new SqlCommand();
+ SqlDataAdapter adapter;
+ SqlParameter param;
+ DataSet ds = new DataSet();
+
+ cmd.Connection = conn;
+ cmd.CommandText = DBConstants.GET_LICENSE_DETAILS_BY_USER_ID;
+ cmd.CommandType = CommandType.StoredProcedure;
- cmd.Connection = conn;
- cmd.CommandText = "GetLicenseDetailByUserId";
- cmd.CommandType = CommandType.StoredProcedure;
+ param = new SqlParameter("@iUserId", userId);
+ param.Direction = ParameterDirection.Input;
+ param.DbType = DbType.Int32;
+ cmd.Parameters.Add(param);
- param = new SqlParameter("@iUserId", userId);
- param.Direction = ParameterDirection.Input;
- param.DbType = DbType.Int32;
- cmd.Parameters.Add(param);
+ adapter = new SqlDataAdapter(cmd);
+ adapter.Fill(ds);
- adapter = new SqlDataAdapter(cmd);
- adapter.Fill(ds);
- if (ds.Tables[0].Rows.Count > 0)
+ if (ds.Tables.Count > 0)
+ {
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ hash.Add(AIAConstants.LICENSE_KEY_ID, ds.Tables[0].Rows[0][0]);
+ hash.Add(AIAConstants.EDITION_KEY_ID, ds.Tables[0].Rows[0][1]);
+ }
+ }
+ }
+ catch (SqlException ex)
{
- hash.Add("LicenseId", ds.Tables[0].Rows[0][0]);
- hash.Add("EditionId", ds.Tables[0].Rows[0][1]);
+ logger.Fatal("Exception in GetUserLicenseDetailByUserId for UserId= " + userId + ", Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
}
+
return hash;
}
- public ArrayList GetUserModulesByLicenseId(int licenseId)
+ internal ArrayList GetUserModulesByLicenseId(int licenseId)
{
- ArrayList userModulelist = new ArrayList();
- Hashtable modulesHash;
- DataSet ds = new DataSet();
+ ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
+ logger.Debug(" Inside GetUserModulesByLicenseId for LicenseId = " + licenseId);
- conn = new SqlConnection(dbConnectionString);
- cmd = new SqlCommand();
- SqlDataAdapter adapter;
- SqlParameter param;
+ ArrayList userModulelist = new ArrayList();
- cmd.Connection = conn;
- cmd.CommandText = "GetUserModulesByLicenseId";
- cmd.CommandType = CommandType.StoredProcedure;
+ try
+ {
+ Hashtable modulesHash;
+ DataSet ds = new DataSet();
- param = new SqlParameter("@iLicenseId", licenseId);
- param.Direction = ParameterDirection.Input;
- param.DbType = DbType.Int32;
- cmd.Parameters.Add(param);
+ conn = new SqlConnection(dbConnectionString);
+ cmd = new SqlCommand();
+ SqlDataAdapter adapter;
+ SqlParameter param;
- adapter = new SqlDataAdapter(cmd);
- adapter.Fill(ds);
- DataTable dt = ds.Tables[0];
+ cmd.Connection = conn;
+ cmd.CommandText = DBConstants.GET_USER_MODULES_BY_LICENSE_ID;
+ cmd.CommandType = CommandType.StoredProcedure;
- foreach (DataRow dr in dt.Rows)
- {
- modulesHash = new Hashtable();
- modulesHash.Add("name", dr["Title"]);
- modulesHash.Add("slug", dr["Slug"]);
- userModulelist.Add(modulesHash);
- }
+ param = new SqlParameter("@iLicenseId", licenseId);
+ param.Direction = ParameterDirection.Input;
+ param.DbType = DbType.Int32;
+ cmd.Parameters.Add(param);
- return userModulelist;
- }
+ adapter = new SqlDataAdapter(cmd);
+ adapter.Fill(ds);
+
- public ArrayList GetUserModulesList(ArrayList allModules, ArrayList modulesByLicense)
- {
- ArrayList userModules = new ArrayList();
- Hashtable moduleHash;
- foreach (Hashtable module in allModules)
- {
- foreach (Hashtable userModule in modulesByLicense)
+ if (ds.Tables.Count > 0)
{
- if ((userModule["Title"].ToString().Trim() == module["name"].ToString().Trim()) && (Convert.ToBoolean(userModule["Status"]) == true))
- {
- moduleHash = new Hashtable();
- moduleHash.Add("name", userModule["Title"]);
- moduleHash.Add("slug", module["slug"]);
+ DataTable dt = ds.Tables[0];
- userModules.Add(moduleHash);
+ if (dt.Rows.Count > 0)
+ {
+ foreach (DataRow dr in dt.Rows)
+ {
+ modulesHash = new Hashtable();
+ modulesHash.Add(AIAConstants.KEY_NAME, dr["Title"]);
+ modulesHash.Add(AIAConstants.KEY_SLUG, dr["Slug"]);
+ userModulelist.Add(modulesHash);
+ }
}
}
}
- return userModules;
+ catch (SqlException ex)
+ {
+ logger.Fatal("Exception in GetUserModulesByLicenseId for LicenseId = " + licenseId + ", Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
+ }
+
+ return userModulelist;
}
protected string GetUserTypeStringById(int userTypeId)
@@ -271,38 +258,38 @@ namespace AIAHTML5.API.Models
switch (userTypeId)
{
- case 1:
+ case (int)UserType.SUPER_ADMIN:
userType = User.SUPER_ADMIN;
break;
- case 2:
+ case (int)UserType.GENERAL_ADMIN:
userType = User.GENERAL_ADMIN;
break;
- case 3:
+ case (int)UserType.DISTRICT_ADMIN:
userType = User.DISTRICT_ADMIN;
break;
- case 4:
+ case (int)UserType.CLIENT_ADMIN:
userType = User.CLIENT_ADMIN;
break;
- case 5:
+ case (int)UserType.SINGLE_USER:
userType = User.SINGLE_USER;
break;
- case 6:
+ case (int)UserType.CONCURRENT_USER:
userType = User.CONCURRENT_USER;
break;
- case 7:
+ case (int)UserType.RESELLER:
userType = User.RESELLER;
break;
- case 8:
+ case (int)UserType.TEST_ACCOUNT:
userType = User.TEST_ACCOUNT;
break;
- case 9:
+ case (int)UserType.SITE_USER:
userType = User.SITE_USER;
break;
}
return userType;
}
- public static User GetUserDetailsByEmailId(string emailId)
+ internal static User GetUserDetailsByEmailId(string emailId)
{
ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
logger.Debug(" Inside GetUserDetailsByEmailId for emailId = " + emailId);
@@ -310,109 +297,105 @@ namespace AIAHTML5.API.Models
User objUser = new User();
DBModel objModel = new DBModel();
- conn = new SqlConnection(dbConnectionString);
- cmd = new SqlCommand();
- SqlDataAdapter adapter;
- SqlParameter param;
- DataSet ds = new DataSet();
+ try
+ {
- cmd.Connection = conn;
- cmd.CommandText = "GetUserInfoByEmailId";
- cmd.CommandType = CommandType.StoredProcedure;
+ conn = new SqlConnection(dbConnectionString);
+ cmd = new SqlCommand();
+ SqlDataAdapter adapter;
+ SqlParameter param;
+ DataSet ds = new DataSet();
- param = new SqlParameter("@sEmailId", emailId);
- param.Direction = ParameterDirection.Input;
- param.DbType = DbType.String;
- cmd.Parameters.Add(param);
+ cmd.Connection = conn;
+ cmd.CommandText = DBConstants.GET_USER_DETAILS_BY_EMAILID;
+ cmd.CommandType = CommandType.StoredProcedure;
- adapter = new SqlDataAdapter(cmd);
- adapter.Fill(ds);
- DataTable dt = ds.Tables[0];
+ param = new SqlParameter("@sEmailId", emailId);
+ param.Direction = ParameterDirection.Input;
+ param.DbType = DbType.String;
+ cmd.Parameters.Add(param);
- foreach (DataRow dr in dt.Rows)
- {
- foreach (DataColumn dc in dt.Columns)
+ adapter = new SqlDataAdapter(cmd);
+ adapter.Fill(ds);
+
+
+ if (ds.Tables.Count > 0)
{
- if (dc.ColumnName == "Id")
- objUser.Id = Convert.ToInt32(dr[dc]);
- if (dc.ColumnName == "FirstName")
- objUser.FirstName = dr[dc].ToString();
- if (dc.ColumnName == "LastName")
- objUser.LastName = dr[dc].ToString();
- if (dc.ColumnName == "EmailId")
- objUser.EmailId = dr[dc].ToString();
- if (dc.ColumnName == "LoginId")
- objUser.LoginId = dr[dc].ToString();
- if (dc.ColumnName == "Password")
- objUser.Password = dr[dc].ToString();
- if (dc.ColumnName == "SecurityQuestionId")
- {
- int tempVal;
- objUser.SecurityQuestionId = Int32.TryParse(dr[dc].ToString(), out tempVal) ? tempVal : (int?)null;
- }
- if (dc.ColumnName == "SecurityAnswer")
- objUser.SecurityAnswer = dr[dc].ToString();
- if (dc.ColumnName == "CreatorId")
- {
- int tempVal;
- objUser.CreatorId = Int32.TryParse(dr[dc].ToString(), out tempVal) ? tempVal : (int?)null;
- }
- if (dc.ColumnName == "CreationDate")
- objUser.CreationDate = Convert.ToDateTime(dr[dc]);
- if (dc.ColumnName == "DeactivationDate")
- {
- DateTime? date;
- if (dr[dc] == DBNull.Value)
- date = null;
- else
- date = (DateTime)dr[dc];
+ DataTable dt = ds.Tables[0];
- objUser.DeactivationDate = date;
- }
- if (dc.ColumnName == "ModifierId")
+ if (dt.Rows.Count > 0)
{
- int tempVal;
- objUser.ModifierId = Int32.TryParse(dr[dc].ToString(), out tempVal) ? tempVal : (int?)null;
- }
- if (dc.ColumnName == "ModifiedDate")
- {
- DateTime? date;
- if (dr[dc] == DBNull.Value)
- date = null;
- else
- date = (DateTime)dr[dc];
-
- objUser.ModifiedDate = date;
+ foreach (DataRow dr in dt.Rows)
+ {
+ int tempVal;
+ DateTime date;
+
+ objUser.Id = Convert.ToInt32(dr["Id"]);
+ objUser.FirstName = dr["FirstName"].ToString();
+ objUser.LastName = dr["LastName"].ToString();
+ objUser.EmailId = dr["EmailId"].ToString();
+ objUser.LoginId = dr["LoginId"].ToString();
+ objUser.Password = dr["Password"].ToString();
+ objUser.SecurityQuestionId = Int32.TryParse(dr["SecurityQuestionId"].ToString(), out tempVal) ? tempVal : (int?)null;
+ objUser.SecurityAnswer = dr["SecurityAnswer"].ToString(); ;
+ objUser.CreatorId = Int32.TryParse(dr["CreatorId"].ToString(), out tempVal) ? tempVal : (int?)null;
+ objUser.CreationDate = Convert.ToDateTime(dr["CreationDate"]);
+ objUser.DeactivationDate = DateTime.TryParse(dr["DeactivationDate"].ToString(), out date) ? date : (DateTime?)null;
+ objUser.ModifierId = Int32.TryParse(dr["ModifierId"].ToString(), out tempVal) ? tempVal : (int?)null;
+ objUser.ModifiedDate = DateTime.TryParse(dr["ModifiedDate"].ToString(), out date) ? date : (DateTime?)null;
+ objUser.UserTypeId = Convert.ToInt32(dr["UserTypeId"]);
+ objUser.UserType = objModel.GetUserTypeStringById(Convert.ToInt32(dr["UserTypeId"]));
+ objUser.IsActive = Convert.ToBoolean(dr["IsActive"]);
+ }
}
- if (dc.ColumnName == "UserTypeId")
- objUser.UserType = objModel.GetUserTypeStringById(Convert.ToInt32(dr[dc]));
- if (dc.ColumnName == "IsActive")
- objUser.IsActive = Convert.ToBoolean(dr[dc]);
-
}
+ else
+ {
+ objUser = null;
+ }
+ }
+ catch (SqlException ex)
+ {
+ logger.Fatal("Exception in GetUserDetailsByEmailId for emailId = " + emailId + ", Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
}
return objUser;
}
- public static int UpdateUserPassword(dynamic userInfo, string loginId, string emailId)
+ internal static int UpdateUserPassword(dynamic userInfo, string loginId, string emailId)
{
+ ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
+ logger.Debug(" Inside UpdateUserPassword for LoginId: " + loginId + ", EmailId: " + emailId);
+
int result = 0;
- conn = new SqlConnection(dbConnectionString);
- cmd = new SqlCommand();
- cmd.Connection = conn;
- conn.Open();
- cmd.CommandText = "UpdateUserPassword";
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("@sLoginId", loginId);
- cmd.Parameters.AddWithValue("@sEmailId", emailId);
- cmd.Parameters.AddWithValue("@sNewPassword", userInfo["newPassword"].ToString());
- result = cmd.ExecuteNonQuery();
- conn.Close();
+
+ try
+ {
+ conn = new SqlConnection(dbConnectionString);
+ cmd = new SqlCommand();
+ cmd.Connection = conn;
+ conn.Open();
+ cmd.CommandText = DBConstants.UPDATE_USER_PASSWORD;
+ cmd.CommandType = CommandType.StoredProcedure;
+ cmd.Parameters.AddWithValue("@sLoginId", loginId);
+ cmd.Parameters.AddWithValue("@sEmailId", emailId);
+ cmd.Parameters.AddWithValue("@sNewPassword", userInfo["newPassword"].ToString());
+ result = cmd.ExecuteNonQuery();
+ conn.Close();
+ }
+ catch (SqlException ex)
+ {
+ conn.Close();
+ logger.Fatal("Exception in UpdateUserPassword for LoginId: " + loginId + ", EmailId: " + emailId + ", Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
+ }
+ finally
+ {
+ conn.Dispose();
+ }
return result;
}
- public LicenseSubscriptionDetails GetLicenseSubscriptionDetailsByLicenseId(int licenseId)
+ internal LicenseSubscriptionDetails GetLicenseSubscriptionDetailsByLicenseId(int licenseId)
{
ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
logger.Debug(" Inside GetLicenseSubscriptionDetailsByLicenseId for LicenseId = " + licenseId);
@@ -427,7 +410,7 @@ namespace AIAHTML5.API.Models
DataSet ds = new DataSet();
cmd.Connection = conn;
- cmd.CommandText = "GetSubscriptionDetailsByLicenseId";
+ cmd.CommandText = DBConstants.GET_SUBSCRIPTION_DETAILS_BY_LICENSE_ID;
cmd.CommandType = CommandType.StoredProcedure;
param = new SqlParameter("@iLicenseId", licenseId);
@@ -436,64 +419,37 @@ namespace AIAHTML5.API.Models
cmd.Parameters.Add(param);
adapter = new SqlDataAdapter(cmd);
- adapter.Fill(ds);
- DataTable dt = ds.Tables[0];
+ adapter.Fill(ds);
- foreach (DataRow dr in dt.Rows)
+ if (ds.Tables.Count > 0)
{
- foreach (DataColumn dc in dt.Columns)
+ DataTable dt = ds.Tables[0];
+
+ if (dt.Rows.Count > 0)
{
- if (dc.ColumnName == "Id")
- lsd.Id = Convert.ToInt32(dr[dc]);
- if (dc.ColumnName == "LicenseId")
- lsd.LicenseId = Convert.ToInt32(dr[dc]);
- if (dc.ColumnName == "SubscriptionPlanId")
+ foreach (DataRow dr in dt.Rows)
{
int tempVal;
- lsd.SubscriptionPlanId = Int32.TryParse(dr[dc].ToString(), out tempVal) ? tempVal : (int?)null;
+ DateTime date;
+ lsd.Id = Convert.ToInt32(dr["Id"]);
+ lsd.LicenseId = Convert.ToInt32(dr["LicenseId"]);
+ lsd.SubscriptionPlanId = Int32.TryParse(dr["SubscriptionPlanId"].ToString(), out tempVal) ? tempVal : (int?)null;
+ lsd.SubscriptionValidFrom = DateTime.TryParse(dr["SubscriptionValidFrom"].ToString(), out date) ? date : (DateTime?)null;
+ lsd.SubscriptionValidThrough = DateTime.TryParse(dr["SubscriptionValidThrough"].ToString(), out date) ? date : (DateTime?)null;
+ lsd.RenewalDate = DateTime.TryParse(dr["RenewalDate"].ToString(), out date) ? date : (DateTime?)null;
+ lsd.PaymentMode = dr["PaymentMode"].ToString();
+ lsd.TotalAmount = Convert.ToDouble(dr["TotalAmount"]);
+ lsd.AmountPaid = Convert.ToDouble(dr["AmountPaid"]);
+ lsd.AmountPending = Convert.ToDouble(dr["AmountPending"]);
+ lsd.NoOfImages = Convert.ToInt32(dr["NoofImages"]);
}
- if (dc.ColumnName == "SubscriptionValidFrom")
- {
- DateTime? date;
- if (dr[dc] == DBNull.Value)
- date = null;
- else
- date = (DateTime)dr[dc];
-
- lsd.SubscriptionValidFrom = date;
- }
- if (dc.ColumnName == "SubscriptionValidThrough")
- {
- DateTime? date;
- if (dr[dc] == DBNull.Value)
- date = null;
- else
- date = (DateTime)dr[dc];
-
- lsd.SubscriptionValidThrough = date;
- }
- if (dc.ColumnName == "RenewelDate")
- {
- DateTime? date;
- if (dr[dc] == DBNull.Value)
- date = null;
- else
- date = (DateTime)dr[dc];
-
- lsd.RenewalDate = date;
- }
- if (dc.ColumnName == "PaymentMode")
- lsd.PaymentMode = dr[dc].ToString();
- if (dc.ColumnName == "TotalAmount")
- lsd.TotalAmount = Convert.ToDouble(dr[dc]);
- if (dc.ColumnName == "AmountPaid")
- lsd.AmountPaid = Convert.ToDouble(dr[dc]);
- if (dc.ColumnName == "AmountPending")
- lsd.AmountPending = Convert.ToDouble(dr[dc]);
- if (dc.ColumnName == "NoofImages")
- lsd.NoOfImages = Convert.ToInt32(dr[dc]);
}
}
+ else
+ {
+ lsd = null;
+ }
+
}
catch (Exception ex)
{
@@ -503,12 +459,12 @@ namespace AIAHTML5.API.Models
return lsd;
}
- public License GetLicenseDetailsByLicenseId(int licenseId)
+ internal License GetLicenseDetailsByLicenseId(int licenseId)
{
ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
logger.Debug(" inside GetLicenseDetailsByLicenseId for LicenseId = " + licenseId);
- License lic = new License();
+ License license = new License();
try
{
conn = new SqlConnection(dbConnectionString);
@@ -518,7 +474,7 @@ namespace AIAHTML5.API.Models
DataSet ds = new DataSet();
cmd.Connection = conn;
- cmd.CommandText = "GetLicenseDetailsById";
+ cmd.CommandText = DBConstants.GET_LICENSE_DETAILS_BY_ID;
cmd.CommandType = CommandType.StoredProcedure;
param = new SqlParameter("@Id", licenseId);
@@ -528,110 +484,114 @@ namespace AIAHTML5.API.Models
adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds);
- DataTable dt = ds.Tables[0];
- foreach (DataRow dr in dt.Rows)
+ if (ds.Tables.Count > 0)
{
- foreach (DataColumn dc in dt.Columns)
+ DataTable dt = ds.Tables[0];
+ if (dt.Rows.Count > 0)
{
- if (dc.ColumnName == "Id")
- lic.Id = Convert.ToInt32(dr[dc]);
- if (dc.ColumnName == "AccountNumber")
- lic.AccountNumber = dr[dc].ToString();
- if (dc.ColumnName == "LicenseeFirstName")
- lic.LicenseeFirstName = dr[dc].ToString();
- if (dc.ColumnName == "LicenseeLastName")
- lic.LicenseeLastName = dr[dc].ToString();
- if (dc.ColumnName == "LicenseTypeId")
- lic.LicenseTypeId = Convert.ToInt32(dr[dc]);
- if (dc.ColumnName == "InstitutionName")
- lic.InstitutionName = dr[dc].ToString();
- if (dc.ColumnName == "Address1")
- lic.Address1 = dr[dc].ToString();
- if (dc.ColumnName == "Address2")
- lic.Address2 = dr[dc].ToString();
- if (dc.ColumnName == "CountryId")
- lic.CountryId = Convert.ToInt32(dr[dc]);
- if (dc.ColumnName == "StateId")
- lic.StateId = Convert.ToInt32(dr[dc]);
- if (dc.ColumnName == "City")
- lic.City = dr[dc].ToString();
- if (dc.ColumnName == "Zip")
- lic.Zip = dr[dc].ToString();
- if (dc.ColumnName == "Phone")
- lic.Phone = dr[dc].ToString();
- if (dc.ColumnName == "EmailId")
- lic.EmailId = dr[dc].ToString();
- if (dc.ColumnName == "TotalLogins")
- lic.TotalLogins = Convert.ToInt32(dr[dc]);
- if (dc.ColumnName == "AccountTypeId")
- lic.AccountTypeId = Convert.ToInt32(dr[dc]);
- if (dc.ColumnName == "IsActive")
- lic.IsActive = Convert.ToBoolean(dr[dc]);
- if (dc.ColumnName == "IsDistrictSiteLicense")
- lic.IsDistrictSiteLicense = Convert.ToBoolean(dr[dc]);
- if (dc.ColumnName == "CreationDate")
- lic.CreationDate = Convert.ToDateTime(dr[dc]);
- if (dc.ColumnName == "ModifiedDate")
+ foreach (DataRow dr in dt.Rows)
{
- DateTime? date;
- if (dr[dc] == DBNull.Value)
- date = null;
- else
- date = (DateTime)dr[dc];
-
- lic.ModifiedDate = date;
+ DateTime date;
+ license.Id = Convert.ToInt32(dr["Id"]);
+ license.AccountNumber = dr["AccountNumber"].ToString();
+ license.LicenseeFirstName = dr["LicenseeFirstName"].ToString();
+ license.LicenseeLastName = dr["LicenseeLastName"].ToString();
+ license.LicenseTypeId = Convert.ToInt32(dr["LicenseTypeId"]);
+ license.InstitutionName = dr["InstitutionName"].ToString();
+ license.Address1 = dr["Address1"].ToString();
+ license.Address2 = dr["Address2"].ToString();
+ license.CountryId = Convert.ToInt32(dr["CountryId"]);
+ license.StateId = Convert.ToInt32(dr["StateId"]);
+ license.City = dr["City"].ToString();
+ license.Zip = dr["Zip"].ToString();
+ license.Phone = dr["Phone"].ToString();
+ license.EmailId = dr["EmailId"].ToString();
+ license.TotalLogins = Convert.ToInt32(dr["TotalLogins"]);
+ license.AccountTypeId = Convert.ToInt32(dr["AccountTypeId"]);
+ license.IsActive = Convert.ToBoolean(dr["IsActive"]);
+ license.IsDistrictSiteLicense = Convert.ToBoolean(dr["IsDistrictSiteLicense"]);
+ license.CreationDate = Convert.ToDateTime(dr["CreationDate"]);
+ license.ModifiedDate = DateTime.TryParse(dr["ModifiedDate"].ToString(), out date) ? date : (DateTime?)null;
+ license.NoOfRenewals = Convert.ToInt32(dr["NoOfRenewals"]);
+ license.IsTermAccepted = Convert.ToBoolean(dr["IsTermsAccepted"]);
+ license.ProductId = dr["ProductId"].ToString();
}
- if (dc.ColumnName == "NoOfRenewals")
- lic.NoOfRenewals = Convert.ToInt32(dr[dc]);
- if (dc.ColumnName == "IsTermsAccepted")
- lic.IsTermAccepted = Convert.ToBoolean(dr[dc]);
- if (dc.ColumnName == "ProductId")
- lic.ProductId = dr[dc].ToString();
}
}
+ else
+ {
+ license = null;
+ }
}
catch (Exception ex)
{
logger.Fatal("Exception in GetLicenseDetailsByLicenseId for LicenseId= " + licenseId + ", Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
}
- return lic;
+ return license;
}
- public static int UpdateLicenseTermStatus(string accountNumber)
+ internal static int UpdateLicenseTermStatus(string accountNumber)
{
ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
logger.Debug(" inside UpdateLicenseTermStatus for AccountNumber = " + accountNumber);
+
int result = 0;
- conn = new SqlConnection(dbConnectionString);
- cmd = new SqlCommand();
- cmd.Connection = conn;
- conn.Open();
- cmd.CommandText = "UpdateLicenseTermAcceptedStatus";
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("@sAccountNumber", accountNumber);
- result = cmd.ExecuteNonQuery();
- conn.Close();
+
+ try
+ {
+ conn = new SqlConnection(dbConnectionString);
+ cmd = new SqlCommand();
+ cmd.Connection = conn;
+ conn.Open();
+ cmd.CommandText = DBConstants.UPDATE_LICENSE_TERM_STATUS;
+ cmd.CommandType = CommandType.StoredProcedure;
+ cmd.Parameters.AddWithValue("@sAccountNumber", accountNumber);
+ result = cmd.ExecuteNonQuery();
+ conn.Close();
+ }
+ catch (SqlException ex)
+ {
+ logger.Fatal("Exception in UpdateLicenseTermStatus for AccountNumber =" + accountNumber + ", Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
+ }
return result;
}
internal static ArrayList GetTermsOfServiceText()
{
+ ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
+ logger.Debug(" inside GetTermsOfServiceText");
+
ArrayList arrTermsOfService = new ArrayList();
- Hashtable contentHash = null;
- string str = string.Empty;
- string spName = "GetTermsOfServiceText";
- DataSet ds = DBModel.GetSQLData(spName, true);
- DataTable dt = ds.Tables[0];
- foreach (DataRow dr in dt.Rows)
+ try
{
- contentHash = new Hashtable();
- contentHash.Add(AIAConstants.KEY_TITLE, dr["Title"]);
- contentHash.Add(AIAConstants.KEY_CONTENT, dr["Content"]);
- arrTermsOfService.Add(contentHash);
+ Hashtable contentHash = null;
+ string str = string.Empty;
+ string spName = DBConstants.GET_TERMS_OF_SERVICE_TEXT;
+ DataSet ds = DBModel.GetDataFromStoredProcedure(spName);
+
+ if (ds.Tables.Count > 0)
+ {
+ DataTable dt = ds.Tables[0];
+ if (dt.Rows.Count > 0)
+ {
+ foreach (DataRow dr in dt.Rows)
+ {
+ contentHash = new Hashtable();
+ contentHash.Add(AIAConstants.KEY_TITLE, dr["Title"]);
+ contentHash.Add(AIAConstants.KEY_CONTENT, dr["Content"]);
+ arrTermsOfService.Add(contentHash);
+ }
+ }
+ }
+ }
+ catch (SqlException ex)
+ {
+ logger.Fatal("Exception in GetTermsOfServiceText, Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
}
+
return arrTermsOfService;
}
@@ -647,7 +607,7 @@ namespace AIAHTML5.API.Models
cmd = new SqlCommand();
cmd.Connection = conn;
conn.Open();
- cmd.CommandText = "InsertLoginDetail";
+ cmd.CommandText = DBConstants.INSERT_LOGIN_DETAIL;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@iUserId", userId);
result = cmd.ExecuteNonQuery();
@@ -658,10 +618,15 @@ namespace AIAHTML5.API.Models
conn.Close();
logger.Fatal("Exception in InsertLoginDetails for UserId= " + userId + ", Exception= " + ex.Message + ", STACKTRACE=" + ex.StackTrace);
}
+ finally
+ {
+ conn.Dispose();
+ }
+
return result;
}
- public int InsertIncorrectLoginAttempts(int userId)
+ internal int InsertIncorrectLoginAttempts(int userId)
{
ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
logger.Debug(" inside InsertIncorrectLoginAttempts for UserId= " + userId);
@@ -673,7 +638,7 @@ namespace AIAHTML5.API.Models
cmd = new SqlCommand();
cmd.Connection = conn;
conn.Open();
- cmd.CommandText = "InsertIncorrectLoginAttempt";
+ cmd.CommandText = DBConstants.INSERT_INCORRECT_LOGIN_ATTEMPTS;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@iUserId", userId);
result = cmd.ExecuteNonQuery();
@@ -681,35 +646,48 @@ namespace AIAHTML5.API.Models
}
catch (SqlException ex)
{
+ conn.Close();
logger.Fatal("Exception in InsertIncorrectLoginAttempts for UserId= " + userId + ", Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
}
+ finally
+ {
+ conn.Dispose();
+ }
return result;
}
- public int GetIncorrectLoginAttempts(int userId)
+ internal int GetIncorrectLoginAttempts(int userId)
{
ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
logger.Debug(" inside GetIncorrectLoginAttempts for UserId = " + userId);
+
int count = 0;
try
{
conn = new SqlConnection(dbConnectionString);
cmd = new SqlCommand();
cmd.Connection = conn;
- cmd.CommandText = "GetIncorrectLoginAttempt";
+ cmd.CommandText = DBConstants.GET_INCORRECT_LOGIN_ATTEMPTS;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@iUserId", userId);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
- DataTable dt = ds.Tables[0];
- foreach (DataRow dr in dt.Rows)
+ if (ds.Tables.Count > 0)
{
- foreach (DataColumn dc in dt.Columns)
+ DataTable dt = ds.Tables[0];
+
+ if (dt.Rows.Count > 0)
{
- count = Convert.ToInt32(dr[dc]);
+ foreach (DataRow dr in dt.Rows)
+ {
+ foreach (DataColumn dc in dt.Columns)
+ {
+ count = Convert.ToInt32(dr[dc]);
+ }
+ }
}
}
}
@@ -732,7 +710,7 @@ namespace AIAHTML5.API.Models
cmd = new SqlCommand();
cmd.Connection = conn;
conn.Open();
- cmd.CommandText = "UpdateIncorrectLoginAttempts";
+ cmd.CommandText = DBConstants.UPDATE_INCORRECT_LOGIN_ATTEMPTS;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@iUserId", userId);
result = cmd.ExecuteNonQuery();
@@ -743,6 +721,10 @@ namespace AIAHTML5.API.Models
conn.Close();
logger.Fatal("Exception in UpdateIncorrectLoginAttempts for UserId= " + userId + ", Exception= " + ex.Message + ", STACKTRACE=" + ex.StackTrace);
}
+ finally
+ {
+ conn.Dispose();
+ }
return result;
}
@@ -758,7 +740,7 @@ namespace AIAHTML5.API.Models
cmd = new SqlCommand();
cmd.Connection = conn;
conn.Open();
- cmd.CommandText = "DeleteIncorrectLoginAttempts";
+ cmd.CommandText = DBConstants.DELETE_INCORRECT_LOGIN_ATTEMPTS;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@iUserId", userId);
result = cmd.ExecuteNonQuery();
@@ -769,25 +751,47 @@ namespace AIAHTML5.API.Models
conn.Close();
logger.Fatal("Exception in DeleteIncorrectLoginAttempts for UserId= " + userId + ", Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
}
+ finally
+ {
+ conn.Dispose();
+ }
return result;
}
protected ArrayList GetLoginFailureCauses()
{
+ ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
+ logger.Debug(" Inside GetLoginFailureCauses");
+
ArrayList failureCauseList = new ArrayList();
- Hashtable fcHash = null;
- string sp = "GetAllLoginFailureCauses";
+ try
+ {
+ Hashtable fcHash = null;
+
+ string sp = DBConstants.GET_ALL_LOGIN_FAILURE_CAUSES;
- DataSet ds = DBModel.GetSQLData(sp, true);
- DataTable dt = ds.Tables[0];
+ DataSet ds = DBModel.GetDataFromStoredProcedure(sp);
+
+ if (ds.Tables.Count > 0)
+ {
+ DataTable dt = ds.Tables[0];
- foreach (DataRow drFailureCause in dt.Rows)
+ if (dt.Rows.Count > 0)
+ {
+ foreach (DataRow drFailureCause in dt.Rows)
+ {
+ fcHash = new Hashtable();
+ fcHash.Add(AIAConstants.KEY_ID, drFailureCause["Id"]);
+ fcHash.Add(AIAConstants.KEY_DESCRIPTION, drFailureCause["Description"]);
+ failureCauseList.Add(fcHash);
+ }
+ }
+ }
+ }
+ catch (SqlException ex)
{
- fcHash = new Hashtable();
- fcHash.Add(AIAConstants.KEY_ID, drFailureCause["Id"]);
- fcHash.Add(AIAConstants.KEY_DESCRIPTION, drFailureCause["Description"]);
- failureCauseList.Add(fcHash);
+ logger.Fatal("Exception in GetLoginFailureCauses, Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
}
return failureCauseList;
}
@@ -804,7 +808,7 @@ namespace AIAHTML5.API.Models
cmd = new SqlCommand();
cmd.Connection = conn;
conn.Open();
- cmd.CommandText = "InsertLoginErrorLog";
+ cmd.CommandText = DBConstants.INSERT_LOGIN_ERROR_LOG;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@nvAccountNumber", accountNumber);
cmd.Parameters.AddWithValue("@dtLogDate", DateTime.Now);
@@ -817,12 +821,17 @@ namespace AIAHTML5.API.Models
}
catch (SqlException ex)
{
+ conn.Close();
logger.Fatal("Exception in InsertUserLoginLog for AccountNumber= " + accountNumber + ", Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
}
+ finally
+ {
+ conn.Dispose();
+ }
return result;
}
- protected BlockedUser GetBlockedUserByUserId(int userId)
+ internal BlockedUser GetBlockedUserByUserId(int userId)
{
ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
logger.Debug(" inside GetBlockedUserByUserId for UserId= " + userId);
@@ -834,7 +843,7 @@ namespace AIAHTML5.API.Models
conn = new SqlConnection(dbConnectionString);
cmd = new SqlCommand();
cmd.Connection = conn;
- cmd.CommandText = "GetBlockedUserByUserId";
+ cmd.CommandText = DBConstants.GET_BLOCKED_USER_BY_USER_ID;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@userId", userId);
SqlDataAdapter da = new SqlDataAdapter();
@@ -846,25 +855,14 @@ namespace AIAHTML5.API.Models
{
foreach (DataRow dr in dt.Rows)
{
- foreach (DataColumn dc in dt.Columns)
- {
- if (dc.ColumnName == "Id")
- blockedUser.Id = Convert.ToInt32(dr[dc]);
- if (dc.ColumnName == "FirstName")
- blockedUser.FirstName = dr[dc].ToString();
- if (dc.ColumnName == "LastName")
- blockedUser.LastName = dr[dc].ToString();
- if (dc.ColumnName == "EmailId")
- blockedUser.EmailId = dr[dc].ToString();
- if (dc.ColumnName == "LoginId")
- blockedUser.LoginId = dr[dc].ToString();
- if (dc.ColumnName == "Password")
- blockedUser.Password = dr[dc].ToString();
- if (dc.ColumnName == "AccountNumber")
- blockedUser.AccountNumber = dr[dc].ToString();
- if (dc.ColumnName == "LoginTime")
- blockedUser.LoginTime = Convert.ToDateTime(dr[dc]);
- }
+ blockedUser.Id = Convert.ToInt32(dr["Id"]);
+ blockedUser.FirstName = dr["FirstName"].ToString();
+ blockedUser.LastName = dr["LastName"].ToString();
+ blockedUser.EmailId = dr["EmailId"].ToString();
+ blockedUser.LoginId = dr["LoginId"].ToString();
+ blockedUser.Password = dr["Password"].ToString();
+ blockedUser.AccountNumber = dr["AccountNumber"].ToString();
+ blockedUser.LoginTime = Convert.ToDateTime(dr["LoginTime"]);
}
}
else
@@ -879,7 +877,7 @@ namespace AIAHTML5.API.Models
return blockedUser;
}
- protected ArrayList GetBlockedAdminUsers(int userTypeId)
+ protected ArrayList GetBlockedUsersByUserType(int userTypeId)
{
ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
logger.Debug(" inside GetBlockedAdminUsers for UserTypeId= " + userTypeId);
@@ -892,7 +890,7 @@ namespace AIAHTML5.API.Models
conn = new SqlConnection(dbConnectionString);
cmd = new SqlCommand();
cmd.Connection = conn;
- cmd.CommandText = "GetBlockedUserByUserType";
+ cmd.CommandText = DBConstants.GET_BLOCKED_USERS_BY_USER_TYPE;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@iUserTypeId", userTypeId);
SqlDataAdapter da = new SqlDataAdapter();
@@ -905,28 +903,23 @@ namespace AIAHTML5.API.Models
foreach (DataRow dr in dt.Rows)
{
blockedUser = new BlockedUser();
- foreach (DataColumn dc in dt.Columns)
- {
- if (dc.ColumnName == "Id")
- blockedUser.Id = Convert.ToInt32(dr[dc]);
- if (dc.ColumnName == "FirstName")
- blockedUser.FirstName = dr[dc].ToString();
- if (dc.ColumnName == "LastName")
- blockedUser.LastName = dr[dc].ToString();
- if (dc.ColumnName == "EmailId")
- blockedUser.EmailId = dr[dc].ToString();
- if (dc.ColumnName == "LoginId")
- blockedUser.LoginId = dr[dc].ToString();
- if (dc.ColumnName == "Password")
- blockedUser.Password = dr[dc].ToString();
- if (dc.ColumnName == "AccountNumber")
- blockedUser.AccountNumber = dr[dc].ToString();
- if (dc.ColumnName == "LoginTime")
- blockedUser.LoginTime = Convert.ToDateTime(dr[dc]);
- }
+
+ blockedUser.Id = Convert.ToInt32(dr["Id"]);
+ blockedUser.FirstName = dr["FirstName"].ToString();
+ blockedUser.LastName = dr["LastName"].ToString();
+ blockedUser.EmailId = dr["EmailId"].ToString();
+ blockedUser.LoginId = dr["LoginId"].ToString();
+ blockedUser.Password = dr["Password"].ToString();
+ blockedUser.AccountNumber = dr["AccountNumber"].ToString();
+ blockedUser.LoginTime = Convert.ToDateTime(dr["LoginTime"]);
+
blockedUsersList.Add(blockedUser);
}
}
+ else
+ {
+ blockedUser = null;
+ }
}
catch (SqlException ex)
{
@@ -935,7 +928,7 @@ namespace AIAHTML5.API.Models
return blockedUsersList;
}
- public static int UnblockUser(int userId)
+ internal static int UnblockUser(int userId)
{
int result = 0;
DBModel objModel = new DBModel();
@@ -945,52 +938,27 @@ namespace AIAHTML5.API.Models
return result;
}
- internal static bool ValidateUserAuthenticity(string username, string password)
+ internal static bool ValidateUserAuthenticity(string username, string password, User user)
{
ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
logger.Debug(" Inside ValidateUserAuthenticity for Username = " + username + ", Password: " + password);
- User objUser = new User();
- DBModel objModel = new DBModel();
-
- conn = new SqlConnection(dbConnectionString);
- cmd = new SqlCommand();
- SqlDataAdapter da = new SqlDataAdapter();
- SqlParameter param;
- DataSet ds = new DataSet();
-
- cmd.Connection = conn;
- cmd.CommandText = "GetUserDetailsByLoginId";
- cmd.CommandType = CommandType.StoredProcedure;
-
- param = new SqlParameter("@sLoginId", username);
- param.Direction = ParameterDirection.Input;
- param.DbType = DbType.String;
- cmd.Parameters.Add(param);
-
- da.SelectCommand = cmd;
- DataTable dt = new DataTable();
- da.Fill(dt);
-
bool result = false;
- if (dt.Rows.Count > 0)
+ try
{
- foreach (DataRow dr in dt.Rows)
+ if ((string.Equals(username.ToUpper(), user.LoginId.ToUpper())) && (string.Equals(password, user.Password)))
{
- foreach (DataColumn dc in dt.Columns)
- {
- if (dc.ColumnName == "LoginId")
- objUser.LoginId = dr[dc].ToString();
- if (dc.ColumnName == "Password")
- objUser.Password = dr[dc].ToString();
- }
- }
-
- if ((string.Equals(username.ToUpper(), objUser.LoginId.ToUpper())) && (string.Equals(password, objUser.Password)))
result = true;
+ }
else
+ {
result = false;
+ }
+ }
+ catch (SqlException ex)
+ {
+ logger.Fatal("Exception in ValidateUserAuthenticity for Username = " + username + ", Password: " + password + ", Exception= " + ex.Message + ", STACKTRACE= " + ex.StackTrace);
}
return result;