
-
Loading...
-
etha66
- Joined on 02-25-2008, 8:05 AM
- Posts 34
|
Hi!
lol,Still got pbms! so i send you copy of my BLL/ads.vb code,and DAL/ads.xsd code as i modified it to add "phone". Can you say me what's wrong?
BLL/ads.vb code:
Imports System
Imports System.Web
Imports System.Web.Security
Imports System.Text
Imports System.Net.Mail
Imports System.Collections
Imports System.Collections.Generic
Imports AdsDataComponentTableAdapters
Imports AspNet.StarterKits.Classifieds.WebNamespace AspNet.StarterKits.Classifieds.BusinessLogicLayer
''' <summary>
''' Describes the type of an ad: "For Sale" or "Wanted."
''' "Unspecified" is used to indicate a variable of this type has not yet been set.
''' </summary>Public Enum AdType
Unspecified = 0
ForSale = 1
Wanted = 2
End Enum
''' <summary>
''' Describes the level, or priority, of an ad.
''' This value is used when ordering results (highest to lowest)
''' on search queries and it can affect the display of rows.
'''
''' "Featured" indicates that the ad will be selected by the "Featured Ad" control
''' that rotates ads to display on the site.
''' "Unspecified" is used to indicate a variable of this type has not yet been set.
'''
''' Use this enumeration to differentiate ads with different priorities
''' or even price points.
''' </summary>Public Enum AdLevel
Unspecified = 0
Normal = 10
Featured = 50
End Enum
''' <summary>
''' Describes the status of an ad:
''' Only ads with positive AdStatus values will be displayed on the public site;
''' administrators will be able to see all.
'''
'''
'''
''' "Unspecified" is used to indicate a variable of this type has not yet been set.
''' </summary>Public Enum AdStatus
ActivationPending = -200
Deleted = -100
Inactive = -50
Unspecified = 0
Activated = 100
End EnumPublic NotInheritable Class AdsDB
Private Sub New()
End Sub
#Region "InsertingAds"
Public Shared Function InsertAd(ByVal memberId As Integer, ByVal categoryId As Integer, ByVal title As String, ByVal description As String, ByVal url As String, ByVal price As Decimal, ByVal location As String, ByVal numDaysActive As Integer, ByVal adLevel As AdLevel, ByVal adStatus As AdStatus, ByVal adType As AdType, ByVal Phone As String) As IntegerDim s As SiteSettings = SiteSettings.GetSharedSettings()
Dim numViews As Integer = 0Dim numResponses As Integer = 0
Dim dateCreated As DateTime = DateTime.NowDim dateApproved As System.Nullable(Of DateTime)
If numDaysActive > s.MaxAdRunningDays Then
numDaysActive = s.MaxAdRunningDays
End If
If numDaysActive < 1 Then
numDaysActive = 1
End IfDim expirationDate As DateTime = DateTime.Today.AddDays(numDaysActive)
If s.AdActivationRequired Then
adStatus = adStatus.ActivationPending
dateApproved = Nothing
Else
adStatus = adStatus.Activated
dateApproved = dateCreated
End If
If adLevel = adLevel.Unspecified Then
adLevel = adLevel.Normal
End IfDim adId As Integer = DefaultValues.IdNullValue
Dim ad As AdsDataComponent.AdsRow = NothingUsing db As New AdsDataAdapter()
adId = CInt(db.InsertAd(memberId, categoryId, title, description, url, price, location, expirationDate, dateCreated, dateApproved, numViews, numResponses, CInt(adLevel), CInt(adStatus), CInt(adType), ))
If s.AdminNotification = AdminNotificationSetting.EachAd Then
ad = GetFirstRow(db.GetAdById(adId))
End If
End Using
If Not (ad Is Nothing) Then
Maintenance.SendAdNotification(ad)
End IfReturn adId
End FunctionPublic Shared Sub InsertSavedAd(ByVal adId As Integer, ByVal memberId As Integer)Using db As New AdsDataAdapter()
db.InsertSavedAd(adId, memberId)
End Using
End SubPublic Shared Sub InsertSavedAdList(ByVal adIds As List(Of Integer), ByVal memberId As Integer)
Using db As New AdsDataAdapter()
Dim i As IntegerFor i = 0 To adIds.Count - 1
db.InsertSavedAd(adIds(i), memberId) Next i
End UsingEnd Sub
#End Region
#Region "GetAds..."Public Shared Function GetAdById(ByVal adId As Integer) As AdsDataComponent.AdsRow
Using db As New AdsDataAdapter()Return GetFirstRow(db.GetAdById(adId))
End UsingEnd Function
Public Shared Function GetActiveAdsByQuery(ByVal recordLimit As Integer, ByVal categoryId As Integer, ByVal memberId As Integer, ByVal maxPrice As Decimal, ByVal searchTerm As String, ByVal location As String, ByVal adType As Integer, ByVal adLevel As Integer, ByVal dayRange As Integer, ByVal mustHaveImage As Boolean) As AdsDataComponent.AdsDataTable
Dim escapedSearchTerm As String = AdsDB.EscapeWildcardCharacters(searchTerm)Dim escapedLocation As String = AdsDB.EscapeWildcardCharacters(location)Return GetAdsByQuery(recordLimit, _
categoryId, memberId, maxPrice, _
HttpUtility.HtmlEncode(escapedSearchTerm), _
HttpUtility.HtmlEncode(escapedLocation), _ adType, CInt(AdStatus.Activated), _
adLevel, dayRange, mustHaveImage) End Function
Public Shared Function GetAdsByQuery(ByVal recordLimit As Integer, ByVal categoryId As Integer, ByVal memberId As Integer, ByVal maxPrice As Decimal, ByVal searchTerm As String, ByVal location As String, ByVal adType As Integer, ByVal adStatus As Integer, ByVal adLevel As Integer, ByVal dayRange As Integer, ByVal mustHaveImage As Boolean) As AdsDataComponent.AdsDataTable
Dim minCreatedDate As System.Nullable(Of DateTime)
If location Is Nothing Then
location = ""
End If
If dayRange > 0 Then
minCreatedDate = DateTime.Now.Subtract(TimeSpan.FromDays(dayRange))
End If
' To return no results if the searchTerm is empty remove the following
' check on the searchTerm.
If searchTerm Is Nothing Then
searchTerm = ""
End IfUsing db As New AdsDataAdapter()
Dim aa As AdsDataComponent.AdsDataTable = Nothing
aa = db.GetAllAdsByQuery(recordLimit, categoryId, memberId, maxPrice, searchTerm, location, adType, adStatus, adLevel, minCreatedDate, mustHaveImage) Return aa
End UsingEnd Function
Public Shared Function GetPendingAds() As AdsDataComponent.AdsDataTable
Return GetAdsByStatus(AdStatus.ActivationPending, DefaultValues.IdNullValue)End Function
Public Shared Function GetPendingAds(ByVal memberId As Integer) As AdsDataComponent.AdsDataTable
Return GetAdsByStatus(AdStatus.ActivationPending, memberId)End Function
Public Shared Function GetActiveAds(ByVal memberId As Integer) As AdsDataComponent.AdsDataTable
Return GetAdsByStatus(AdStatus.Activated, memberId)End Function
Public Shared Function GetInactiveAds(ByVal memberId As Integer) As AdsDataComponent.AdsDataTable
Return GetAdsByStatus(AdStatus.Inactive, memberId)End Function 'GetInactiveAds
Public Shared Function GetAdsByStatus(ByVal adStatus As AdStatus, ByVal memberId As Integer) As AdsDataComponent.AdsDataTable
Using db As New AdsDataAdapter()Return db.GetAdsByStatus(CInt(adStatus), memberId)
End UsingEnd Function
Public Shared Function GetAdsByStatus(ByVal adStatus As AdStatus) As AdsDataComponent.AdsDataTable
Return GetAdsByStatus(adStatus, DefaultValues.IdNullValue)End Function
Public Shared Function GetFeaturedAdsSelection(ByVal maxNumAds As Integer) As AdsDataComponent.AdsDataTable
If maxNumAds < 1 Then
Return Nothing
End IfUsing db As New AdsDataAdapter()
Return db.GetAdsByRandomOrder(maxNumAds, CInt(AdStatus.Activated), CInt(AdLevel.Featured))
End UsingEnd Function
Public Shared Function GetSavedAds(ByVal memberId As Integer) As AdsDataComponent.AdsDataTable
Using db As New AdsDataAdapter()Return db.GetSavedAds(memberId)
End UsingEnd Function
#End Region
#Region "Update Ads"Public Shared Sub UpdateAd(ByVal original_Id As Integer, ByVal memberId As Integer, ByVal title As String, ByVal description As String, ByVal url As String, ByVal price As Decimal, ByVal location As String, ByVal isRelisting As Boolean)
If (url Is Nothing) Thenurl = String.Empty
End IfUsing db As New AdsDataAdapter()
db.UpdateAd(original_Id, memberId, _
HttpUtility.HtmlEncode(title), _
HttpUtility.HtmlEncode(description), _
HttpUtility.UrlEncode(url), _
price, _
HttpUtility.HtmlEncode(location))
End UsingEnd Sub
Public Shared Sub RelistAd(ByVal adId As Integer, ByVal categoryId As Integer, ByVal title As String, ByVal description As String, ByVal url As String, ByVal price As Decimal, ByVal location As String, ByVal numDaysActive As Integer, ByVal adLevel As AdLevel, ByVal adStatus As AdStatus, ByVal adType As AdType)
Dim s As SiteSettings = SiteSettings.GetSharedSettings()Dim dateCreated As DateTime = DateTime.Now
Dim dateApproved As System.Nullable(Of DateTime)
If numDaysActive > s.MaxAdRunningDays Then
numDaysActive = s.MaxAdRunningDays
End If
If numDaysActive < 1 Then
numDaysActive = 1
End IfDim expirationDate As DateTime = DateTime.Today.AddDays(numDaysActive)
If s.AdActivationRequired Then
adStatus = adStatus.ActivationPending
dateApproved = Nothing
Else
adStatus = adStatus.Activated
dateApproved = dateCreated
End If
If adLevel = adLevel.Unspecified Then
adLevel = adLevel.Normal
End If
Dim ad As AdsDataComponent.AdsRow = NothingUsing db As New AdsDataAdapter()
db.RelistAd(adId, categoryId, title, description, url, price, location, expirationDate, dateCreated, dateApproved, CInt(adLevel), CInt(adStatus), CInt(adType))
If s.AdminNotification = AdminNotificationSetting.EachAd Then
ad = GetFirstRow(db.GetAdById(adId))
End If
End Using
If Not (ad Is Nothing) Then
Maintenance.SendAdNotification(ad)
End IfEnd Sub
Public Shared Sub IncrementViewCount(ByVal adId As Integer)Using db As New AdsDataAdapter()
db.UpdateAdStats(adId, 1, 0)
End UsingEnd Sub
Public Shared Sub IncrementResponseCount(ByVal adId As Integer)Using db As New AdsDataAdapter()
db.UpdateAdStats(adId, 0, 1)
End UsingEnd Sub
Public Shared Sub UpdateAdCategory(ByVal adId As Integer, ByVal categoryId As Integer)Using db As New AdsDataAdapter()
db.UpdateAdCategory(adId, categoryId)
End UsingEnd Sub
Public Shared Sub UpdateAdLevel(ByVal adId As Integer, ByVal adLevel As AdLevel)
Using db As New AdsDataAdapter()db.UpdateAdLevel(adId, CInt(adLevel))
End UsingEnd Sub
Public Shared Sub UpdateAdLevelList(ByVal adIds As List(Of Integer), ByVal adLevel As AdLevel | |