aDEFWEBSERVER
Los Angeles, CA *  Webmaster@ADefWebserver.com

Creating a DotNetNuke® Module For absolute beginners!
For DotNetNuke Version 4 - Page 5 (Page 4)

   

The Business Logic Layer (BLL)

To build the Business Logic Layer we will:

And that's it! This is the step that is usually the hardest for beginners to understand but is really not that complicated. However, ASP.NET 2.0 does provide a major reduction of code over the ASP.NET 1.1 version.

 

Alter the "GuestBookInfo.vb" file

In Visual Studio, select VIEW from the toolbar and "Solution Explorer"
In the Solution Explorer, expand the "GuestBook" directory under the "App_code" folder and double-click on the "GuestBookInfo.vb" file.
Replace every single line of code in the file with this code:  

Imports System
Imports
System.Configuration
Imports
System.Data

Namespace YourCompany.Modules.GuestBook

Public Class GuestBookInfo

Private _ModuleId As Integer
Private
_ID As Integer
Private
_Name As String
Private
_Email As String
Private
_Message As String
Private
_DateEntered As DateTime

' initialization

Public Sub New()
 
MyBase.New()
End Sub

' <summary>
' Gets and sets the Module Id
' </summary>

Public Property ModuleId() As Integer
 Get
  Return
_ModuleId
 End Get
Set
(ByVal value As Integer)
  _ModuleId = value
 End Set
End
Property


' <summary>
' Gets and sets the Item ID
' </summary>
Public Property ID() As Integer
 Get
  Return
_ID
 End Get
 Set
(ByVal value As Integer)
  _ID = value
 End Set
End
Property


' <summary>
' gets and sets the Name
' </summary>
Public Property Name() As String
 Get
  Return
_Name
 End Get
 Set
(ByVal value As String)
  _Name = value
 End Set
End
Property


' <summary>
' Gets and sets the Email
' </summary>
Public Property Email() As String
 Get
  Return
_Email
 End Get
 Set
(ByVal value As String)
  _Email = value
 End Set
End
Property


' <summary>
' Gets and sets the Message
' </summary>
Public Property Message() As String
 Get
  Return
_Message
 End Get
 Set
(ByVal value As String)
  _Message = value
 End Set
End
Property


' <summary>
' Gets and sets the DateEntered
' </summary>
Public Property DateEntered() As DateTime
 Get
  Return
_DateEntered
 End Get
 Set
(ByVal value As DateTime)
  _DateEntered = value
 End Set
 End
Property


 End
Class
End
Namespace

 

Alter the "GuestBookController.vb" file

In Visual Studio, select VIEW from the toolbar and "Solution Explorer"
 
In the Solution Explorer, expand the "GuestBook" directory under the "App_code" folder and double-click on the "GuestBookController.vb" file.
Replace every single line of code in the file with this code:  

Imports System
Imports
System.Collections.Generic
Imports
System.Configuration
Imports
System.ComponentModel
Imports
System.Data
Imports
System.Xml
Imports
System.Web
Imports
DotNetNuke
Imports
DotNetNuke.Common
Imports
DotNetNuke.Common.Utilities
Imports
DotNetNuke.Entities.Modules
Imports
DotNetNuke.Services.Search
 

Namespace YourCompany.Modules.GuestBook

 Public Class GuestBookController

  <DataObjectMethod(DataObjectMethodType.Insert)> _
  Public Shared Sub GuestBook_Insert(ByVal objTest As GuestBookInfo)
    DataProvider.Instance.YourCompany_GuestBook_Insert(objTest.ModuleId,   objTest.Name, objTest.Email, objTest.Message)
  End Sub

  <DataObjectMethod(DataObjectMethodType.Delete)> _
  Public Shared Sub GuestBook_Delete(ByVal objTest As GuestBookInfo)
    DataProvider.Instance.YourCompany_GuestBook_Delete(objTest.ID)
  End Sub

  <DataObjectMethod(DataObjectMethodType.Select)> _
  Public Shared Function GuestBook_GetAll(ByVal ModuleId As Integer) As List(Of   GuestBookInfo)
    Return CBO.FillCollection(Of GuestBookInfo)(DataProvider.Instance().YourCompany_GuestBook_GetAll(ModuleId))
  End Function

  <DataObjectMethod(DataObjectMethodType.Update)> _
  Public Shared Sub GuestBook_Update(ByVal objTest As GuestBookInfo)
    DataProvider.Instance.YourCompany_GuestBook_Update(objTest.ID,   objTest.Name, objTest.Email, objTest.Message, objTest.DateEntered)
  End Sub

 End Class
 

End Namespace

 

Review

  • Data Access Layer (DAL) (Done)
  • Business Logic Layer (BLL) (Done)
  • Presentation Layer (UI)

We are done with the Business Logic Layer.

 

What did we just do?

The "GuestBookInfo.vb" was created. This is just a simple class file. It will hold the data

The "GuestBookController.vb" was created. This class has 4 methods:
  • GuestBook_Insert
    • Inserts items into the database. You pass a "GuestBookInfo" object to this method. The method then opens up the object and passes the individual parameters (ModuleId, Name, Email, Message) to the "YourCompany_GuestBook_Insert" method in the DataProvider.vb" file.
  • GuestBook_Delete
    • Deletes items from the database. You pass a "GuestBookInfo" object to this method. The method then opens up the object and passes the individual parameter (ID) to the "YourCompany_GuestBook_Delete" method in the DataProvider.vb" file.
  • GuestBook_GetAll
    • Gets a recordset from the database. You pass a "ModuleId" parameter to this method. The method calls the "YourCompany_GuestBook_GetAll" method in the  DataProvider.vb" file and returns a "GuestBookInfo" object filled with data.
  • GuestBook_Update
    • Updates the database. You pass a "GuestBookInfo" object to this method. The method then opens up the object and passes the individual parameters (ID, ModuleId, Name, Email, Message, DateEntered) to the "YourCompany_GuestBook_Update" method in the DataProvider.vb" file.

A Lot Of Stuff Was Deleted

You may notice that a lot of code was deleted out of the "GuestBookController.vb" file. Some of this was the optional interfaces that handle exporting data and searching. These are interfaces that you will want to read about and implement in your modules. However, they are not required and they are left out for simplicity.

A lot of code was eliminated by using code that is exclusive to ASP.NET 2.0 and incompatible with ASP.NET 1.1. ASP.NET 2.0 really saves you a lot of work and requires less code.

 
   

BACK
 

Next: The Presentation Layer (UI)

 

   
   
   
DotNetNuke MarketPlace

(C) by Michael Washington - ADefWebserver.com - Webmaster@ADefWebserver.com

DotNetNuke® is a registered trademark of Perpetual Motion Interactive Systems Inc.