public List <LocationParkingLot> GetLoginUserAllocatedLocationLots(User objLoginUser) { List <LocationParkingLot> lstLocationParkingLot = new List <LocationParkingLot>(); string resultMsg = string.Empty; try { using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString())) { using (SqlCommand sqlcmd_obj = new SqlCommand("OPAPP_PROC_GetUserAllocatedStationLots", sqlconn_obj)) { sqlcmd_obj.CommandType = CommandType.StoredProcedure; sqlcmd_obj.Parameters.AddWithValue("@UserID", (objLoginUser.UserID == null || objLoginUser.UserID == 0) ? (object)DBNull.Value : objLoginUser.UserID); sqlcmd_obj.Parameters.AddWithValue("@UserTypeID", (objLoginUser.UserTypeID.UserTypeID == null || objLoginUser.UserTypeID.UserTypeID == 0) ? (object)DBNull.Value : objLoginUser.UserTypeID.UserTypeID); sqlcmd_obj.Parameters.AddWithValue("@UserTypeName", (objLoginUser.UserTypeID.UserTypeName == null || objLoginUser.UserTypeID.UserTypeName == "null") ? (object)DBNull.Value : objLoginUser.UserTypeID.UserTypeName); sqlcmd_obj.Parameters.AddWithValue("@LocationID", (objLoginUser.LocationParkingLotID.LocationID.LocationID == null || objLoginUser.LocationParkingLotID.LocationID.LocationID == 0) ? (object)DBNull.Value : objLoginUser.LocationParkingLotID.LocationID.LocationID); sqlcmd_obj.Parameters.AddWithValue("@LocationParkingLotID", (objLoginUser.LocationParkingLotID.LocationParkingLotID == null || objLoginUser.LocationParkingLotID.LocationParkingLotID == 0) ? (object)DBNull.Value : objLoginUser.LocationParkingLotID.LocationParkingLotID); sqlconn_obj.Open(); SqlDataAdapter sqldap = new SqlDataAdapter(sqlcmd_obj); DataTable resultdt = new DataTable(); sqldap.Fill(resultdt); if (resultdt.Rows.Count > 0) { for (var i = 0; i < resultdt.Rows.Count; i++) { LocationParkingLot objLocationParkingLot = new LocationParkingLot(); objLocationParkingLot.LocationParkingLotID = Convert.ToInt32(resultdt.Rows[i]["LocationParkingLotID"]); objLocationParkingLot.LocationParkingLotName = Convert.ToString(resultdt.Rows[i]["LocationParkingLotName"]); objLocationParkingLot.LocationID.LocationID = Convert.ToInt32(resultdt.Rows[i]["LocationID"]); objLocationParkingLot.LocationID.LocationName = Convert.ToString(resultdt.Rows[i]["LocationName"]); objLocationParkingLot.IsActive = resultdt.Rows[i]["IsHoliday"] == DBNull.Value ? false : Convert.ToBoolean(resultdt.Rows[i]["IsHoliday"]); objLocationParkingLot.LotOpenTime = resultdt.Rows[i]["LotOpenTime"] == DBNull.Value ? "" : Convert.ToString(resultdt.Rows[i]["LotOpenTime"]); objLocationParkingLot.LotCloseTime = resultdt.Rows[i]["LOTCLOSETIME"] == DBNull.Value ? "" : Convert.ToString(resultdt.Rows[i]["LOTCLOSETIME"]); DALLocationLot dalLocation = new DALLocationLot(); var lotavilability = dalLocation.GetLocationLotVehicleAvailabilityDetails(Convert.ToInt32(resultdt.Rows[i]["LocationID"]), Convert.ToInt32(resultdt.Rows[i]["LocationParkingLotID"])); objLocationParkingLot.LotVehicleAvailabilityName = lotavilability.LotVehicleAvailabilityName; lstLocationParkingLot.Add(objLocationParkingLot); } } } } } catch (Exception ex) { objExceptionlog.InsertException("WebAPI", ex.Message, "DALUserLoginVerification", "Proc: " + "OPAPP_PROC_GetUserAllocatedStationLots", "GetLoginUserAllocatedLocationLots"); } return(lstLocationParkingLot); }
public User GetLoginUserDetails(UserLogin objUser) { User objOutPutuser = new User(); objencrypt = new DataEncryptDecrypt(); objpwdencrypt = new PasswordEncryptDecrypt(); string resultMsg = string.Empty; string encryptKey = string.Empty; try { string resultkey = getEncryptdata(objUser.UserName); string pwd = objpwdencrypt.Encrypt(objUser.Password, resultkey); using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString())) { using (SqlCommand sqlcmd_obj = new SqlCommand("OPAPP_PROC_LoginVerification", sqlconn_obj)) { sqlcmd_obj.CommandType = CommandType.StoredProcedure; sqlcmd_obj.Parameters.AddWithValue("@USERNAME", objUser.UserName); sqlcmd_obj.Parameters.AddWithValue("@PASSWORD", pwd); sqlcmd_obj.Parameters.AddWithValue("@Lattitude", objUser.Latitude); sqlcmd_obj.Parameters.AddWithValue("@Longitude", objUser.Longitude); sqlconn_obj.Open(); SqlDataAdapter sqldap = new SqlDataAdapter(sqlcmd_obj); DataTable resultdt = new DataTable(); sqldap.Fill(resultdt); if (resultdt.Rows.Count > 0) { objOutPutuser.UserName = Convert.ToString(resultdt.Rows[0]["USERNAME"]); objOutPutuser.UserCode = Convert.ToString(resultdt.Rows[0]["UserCode"]); objOutPutuser.UserID = resultdt.Rows[0]["UserID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[0]["UserID"]); objOutPutuser.UserTypeID.UserTypeID = resultdt.Rows[0]["UserTypeID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[0]["UserTypeID"]); objOutPutuser.LocationParkingLotID.LocationParkingLotID = resultdt.Rows[0]["LocationParkingLotID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[0]["LocationParkingLotID"]); objOutPutuser.LocationParkingLotID.LocationParkingLotName = Convert.ToString(resultdt.Rows[0]["LocationParkingLotName"]); objOutPutuser.LocationParkingLotID.LocationParkingLotCode = Convert.ToString(resultdt.Rows[0]["LocationParkingLotCode"]); objOutPutuser.LocationParkingLotID.LocationID.LocationID = resultdt.Rows[0]["LocationID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[0]["LocationID"]); objOutPutuser.LocationParkingLotID.LocationID.LocationName = Convert.ToString(resultdt.Rows[0]["LocationName"]); objOutPutuser.UserTypeID.UserTypeName = Convert.ToString(resultdt.Rows[0]["UserTypeName"]); objOutPutuser.LocationParkingLotID.Lattitude = Convert.ToDecimal(objUser.Latitude); objOutPutuser.LocationParkingLotID.Longitude = Convert.ToDecimal(objUser.Longitude); objOutPutuser.PhoneNumber = Convert.ToString(resultdt.Rows[0]["PhoneNumber"]); objOutPutuser.LoginTime = DateTime.Now; objOutPutuser.LoginDeviceID = objUser.LoginDeviceID; objOutPutuser.Photo = resultdt.Rows[0]["Photo"] == DBNull.Value ? null : (byte[])resultdt.Rows[0]["Photo"]; List <LocationParkingLot> lstLocationParkingLots = GetLoginUserAllocatedLocationLots(objOutPutuser); if (lstLocationParkingLots.Count > 0) { LocationParkingLot userlot = lstLocationParkingLots[0]; objOutPutuser.LocationParkingLotID.LotCloseTime = userlot.LotCloseTime; objOutPutuser.LocationParkingLotID.LotOpenTime = userlot.LotOpenTime; if (resultdt.Rows[0]["LocationParkingLotID"] == DBNull.Value) { objOutPutuser.LocationParkingLotID.LocationParkingLotID = userlot.LocationParkingLotID; objOutPutuser.LocationParkingLotID.LocationParkingLotName = userlot.LocationParkingLotName; objOutPutuser.LocationParkingLotID.LocationID.LocationID = userlot.LocationID.LocationID; objOutPutuser.LocationParkingLotID.LocationID.LocationName = userlot.LocationID.LocationName; } DALLocationLot dalLocation = new DALLocationLot(); var lotavilability = dalLocation.GetLocationLotVehicleAvailabilityDetails(userlot.LocationID.LocationID, userlot.LocationParkingLotID); objOutPutuser.LocationParkingLotID.LotVehicleAvailabilityName = lotavilability.LotVehicleAvailabilityName; } } } } } catch (Exception ex) { objExceptionlog.InsertException("WebAPI", ex.Message, "DALUserLoginVerification", "Proc: " + "OPAPP_PROC_LoginVerification", "GetLoginUserDetails"); throw; } return(objOutPutuser); }