1. Projects Portfolio
SetFocus .NET Masters Program
The following contains the projects, project objectives, and
screen captures of various applications completed during the
.NET Masters Program at SetFocus.
Amir Naraghi
anaraghi@verizon.net
484-880-3156
2. SetFocus Project # 1 - .Net Framework
Objective:
To build parts of a business tier catered for a retail company. The business tier would consist of two
assemblies; A Foundation Class Library and an AppTypes Class Library.
Summary:
This project demonstrated the interaction between an n-tiered application, through the use of essential
.NET skills. The following is list of C# and .NET skills used:
Abstract Classes and Interfaces Binary and SOAP Formatters
Delegates and Events Enumerations
Custom EventArgs Properties
Custom Exception/Attribute Class Custom Enumerators Implementation of
Event Logger and Collections Classes ISerializable, IComparer, IComparable, and
Custom Serialization IList<T> interfaces
Generic Collections
Foundation Assembly:
The following Diagram depicts the classes and interfaces developed and used during the project
lifecycle:
Amir Naraghi anaraghi@verizon.net Page 2 of 34
3. SetFocus Project # 1 - .Net Framework
AppTypes Assembly:
The following Diagram depicts the various collection and exception classes designed.
Amir Naraghi anaraghi@verizon.net Page 3 of 34
4. SetFocus Project # 2 (Library Phase I) - .Net Framework
Objective:
To create a Windows Forms-based front-end application that will provide a librarian with a visual
interface through which he or she may perform the desired functions
Summary:
This project demonstrated the use of .NET windows forms development. Some of the techniques
highlighted in the project were:
User input validation using error providers Use of regular expression for input
Data binding to a datagrid view and the validation
manipulation of that control Effective error and exception handling
Incorporate an n-tier architecture for Scalable approach to data validation using a
scalability Class
An intuitive user interface which requires
minimal training
Description:
In order to make the interface as intuitive as possible for the user I implemented a central access point
to the application and a menu strip to access corresponding forms. I designed the form for a clean and
visually appealing appearance as well as incorporating functionality.
The AN.LibraryWinClient Assembly handled the UI and the various form
validation and exception handling. This particular assembly’s code
handled all validation logic, displaying of screens, and any data
manipulation operations performed.
Business Layer (AN.LibraryBusiness) was introduced to act as a gateway
between the Data Access Layer and the UI and also a Validation Class
that contains various static and non-static methods for validating input.
All data provided for this project (book, member, and loan information)
is contained in a SQL Server 2008 Database. The data is retrieved
through a Data Access Layer that was provided to us as a compiled DLL.
Through the use of encapsulation the UI does not perceive how the data
is accessed or input is validated. If future changes are needed on how
data is accessed the front end will not require any manipulation.
Amir Naraghi anaraghi@verizon.net Page 4 of 34
5. SetFocus Project # 2 (Library Phase I) - .Net Framework
Library Operations and Rules:
Member Information:
Member ID must be positive integer values (>0). Also Member ID must be 16-bit integer
value.
Screen displays information about the member's account, such as name, address, phone
number, and the card's expiration date.
Juvenile member’s information will also include the sponsoring adult’s member id, and
date of birth.
Cards that have expired will be highlighted.
The screen also displays information about a member's outstanding loans, including title,
checkout date, and due date.
Add Adult Member:
First name, Last name must be non-empty strings consisting of alphabetic characters
only, with a leading uppercase character and all others in lowercase, at most fifteen
characters in length.
Middle initial is optional, but if entered it must be one uppercase alphabetic character.
Street address and city must be non-empty strings, no more than fifteen characters in
length each.
State must be two uppercase alphabetic characters.
Zip must be a non-empty string in the format: ##### or #####-####, where # is a digit (0-
9).
Phone is optional, but if entered it must be in the format: (###)###-####.
Add Juvenile Member:
First name, Last name must be non-empty strings consisting of alphabetic characters
only, with a leading uppercase character and all others in lowercase, at most fifteen
characters in length.
Middle initial is optional, but if entered it must be one uppercase alphabetic character.
Juvenile member birth date must be a valid date (MM/DD/YYYY format), and the birth
date must fall within the eighteen-year period ending on the current date.
Juvenile Members must have an adult sponsor, validation must make sure that the
member ID passed in is an Actual Adult member
Amir Naraghi anaraghi@verizon.net Page 5 of 34
6. SetFocus Project # 2 (Library Phase I) - .Net Framework
Library Operations and Rules:
Checkout Item:
When checking out an Item the ISBN and copy number must be entered
ISBN, Copy number must be positive integer values (>0). ISBN must be a 32-bit integer
value. Copy number must be 16-bit integer values.
Invalid ISBN and or Copy number should be identified through validation
Member card must be valid (not expired) and member must have fewer than four books
checked out
If a librarian tries to check out a book that the database lists as already checked out, the
librarian should be alerted and be given the opportunity to check the book in before
proceeding with the checkout operation.
Check In Item:
When a book is returned to the library, a librarian checks it in by entering the ISBN and
copy number that appears on the book’s spine.
ISBN, Copy number must be positive integer values (>0). ISBN must be a 32-bit integer
value. Copy number must be 16-bit integer values.
The ISBN, copy number, title, and author information then appear on the computer
screen, as well as the card number and name of the member to whom the book is
checked out, and the book's due date.
The librarian can then elect to check the book in or to cancel the check-in operation.
Amir Naraghi anaraghi@verizon.net Page 6 of 34
7. SetFocus Project # 2 (Library Phase I) - .Net Framework
Project Screen Captures:
Library Home Page
Member Information Page
Amir Naraghi anaraghi@verizon.net Page 7 of 34
8. SetFocus Project # 2 (Library Phase I) - .Net Framework
Project Screen Captures:
Checkout Item off Member Information Page
Add Adult Member
Amir Naraghi anaraghi@verizon.net Page 8 of 34
9. SetFocus Project # 2 (Library Phase I) - .Net Framework
Project Screen Captures:
Add Juvenile Member
Check in Item
Amir Naraghi anaraghi@verizon.net Page 9 of 34
10. SetFocus Project # 3 (Library Phase II) - .Net Framework
Objective:
To increase performance of the library application by developing the middle tier data access and entities
layers provided to us in the first project, and provide added functionality to the existing interfaces.
Summary:
This project demonstrated the use of ADO .NET and SQL stored procedures. Some of the techniques
highlighted in the project were:
Use of ADO Connection, Command, Design and use of a Data Access Interface
DataReader, and DataAdapter Design and use of an Entities Layer
Use of a strongly typed DataSet Use of Stored Procedures for performance
LINQ to SQL ORM and scalability
Custom Exceptions class Effective error and exception handling
Description:
The previous project used pre-created data access and entities layers.
The data access layer employed ADO .NET, however it did not use stored
procedure. I was tasked to re-create the data access layer through the
use of stored procedures for better security, performance and scalability.
In turn I was asked to also re-design the entities layer that was also
provided for us.
In order to create a seamless process I first created all the necessary
stored procedures. I then created the common methods that would be
required as an interface. Inheriting from the interface I had the
foundation to create the data access layer. I then introduced the newly
created data access layer methods one at a time, so as to not disturb the
already existing and referenced classes. Once I was confident the newly
created data access layer and entities was performing properly I
removed all references to the previous data access and entities layers.
The following functionality was also implemented; Overdue items report,
converting juvenile to adult members, highlighting overdue items in the
member information screen, and making sure that an item was loanable.
Amir Naraghi anaraghi@verizon.net Page 10 of 34
11. SetFocus Project # 3 (Library Phase II) - .Net Framework
Library Operations and Rules (Added functionality):
Member Information:
If outstanding loans date of return has expired, highlight item.
th
If a juvenile member is searched and the member has reached his or her 18 birthday,
the member is automatically converted to an adult member with a membership expiration
date of one year past the current date of conversion.
Add Juvenile Member:
Juvenile Members must have an adult sponsor, validation must make sure that the
member ID passed in is an Actual Adult member, and that adult member does not have
an expired membership.
Checkout Item:
Item must be loanable.
Project Screen Captures:
Member Information with highlighted loan
Amir Naraghi anaraghi@verizon.net Page 11 of 34
12. SetFocus Project # 3 (Library Phase II) - .Net Framework
Project Screen Captures:
Member Information (Juvenile to Adult Conversion)
Checkout Item (Item not loanable)
Amir Naraghi anaraghi@verizon.net Page 12 of 34
14. SetFocus Project # 3 (Library Phase II) - .Net Framework
Project Code Sample:
Library Data Access Layer: Get Member Information (ADO .NET)
Library Business Layer: Call to Data Access Layer GetMember Method
Amir Naraghi anaraghi@verizon.net Page 14 of 34
15. SetFocus Project # 3 (Library Phase II) - .Net Framework
Project Code Sample:
Library Data Access Layer: Read Member (ADO .NET)
Amir Naraghi anaraghi@verizon.net Page 15 of 34
16. SetFocus Project # 3 (Library Phase II) - .Net Framework
Project Code Sample:
Library Data Access Layer: Check In Item (ADO .NET)
Library Business Layer: Call to Data Access Layer Check In Item Method
Amir Naraghi anaraghi@verizon.net Page 16 of 34
17. SetFocus Project # 3 (Library Phase II) - .Net Framework
Project Code Sample:
Sample Stored Procedure: Add Adult Member
USE [library]
GO
/****** Object: StoredProcedure [dbo].[AddAdultMember] Script Date: 02/11/2010 22:16:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/* =============================================
-- Author: Amir Naraghi
-- Create date: 1/25/2010
-- Description: Add Adult Member and ouput new adult's member id
-- Revisions:
1/25/2010 - Initial Revision (AN)
-- Error Codes:
LIBEx First Name is null,11,1
LIBEx Last Name is null,11,1
LIBEx Street is null,11,1
LIBEx City is null,11,1
LIBEx State is null,11,1
LIBEx Zip is null,11,1
-- Notes:
============================================= */
ALTER PROCEDURE [dbo].[AddAdultMember]
-- Add the parameters for the stored procedure here
@newMemberID SMALLINT OUTPUT,
@expireDate DATETIME OUTPUT,
@firstName VARCHAR (15) = null,
@lastName VARCHAR (15) = null,
@middleInitial CHAR(1) = null,
@street VARCHAR(15) = null,
@city VARCHAR (15) = null,
@state CHAR(2) = null,
@zip CHAR(10) = null,
@phoneNumber CHAR(13) = null
AS
BEGIN
BEGIN TRY
-- validate firstname
IF @firstName IS NULL
BEGIN
RAISERROR ('LIBEx First Name is null',11,1)
END
-- validate lastname
IF @lastName IS NULL
BEGIN
RAISERROR ('LIBEx Last Name is null',11,1)
END
-- validate street
IF @street IS NULL
BEGIN
RAISERROR ('LIBEx Street is null',11,1)
END
-- validate city
IF @city IS NULL
BEGIN
RAISERROR ('LIBEx City is null',11,1)
END
-- validate state
IF @state IS NULL
BEGIN
RAISERROR ('LIBEx State is null',11,1)
END
-- validate zip code
IF @zip IS NULL
BEGIN
RAISERROR ('LIBEx Zip Code is null',11,1)
END
Amir Naraghi anaraghi@verizon.net Page 17 of 34
18. -- ADD MEMBER
BEGIN TRAN
-- insert into member table and retrieve and set new member id
INSERT INTO [library].[dbo].[member]
([lastname]
,[firstname]
,[middleinitial])
VALUES
(@lastName
,@firstName
,@middleInitial)
-- set new member variable
SET @newMemberID = SCOPE_IDENTITY();
-- set expiration date 1 year after
SET @expireDate = DATEADD (YY,1,GETDATE())
-- insert into adult
INSERT INTO [library].[dbo].[adult]
([member_no]
,[street]
,[city]
,[state]
,[zip]
,[phone_no]
,[expr_date])
VALUES
(@newMemberID
,@street
,@city
,@state
,@zip
,@phoneNumber
,@expireDate)
COMMIT TRAN
RETURN 0
END TRY
--CATCH AND RAISE ERROR BACK UP TO CALLING APPLICATION
BEGIN CATCH
-- rollback transaction
IF @@TRANCOUNT > 0
ROLLBACK TRAN
--declare error variables
DECLARE @ERR_MSG NVARCHAR (1000)
DECLARE @ERR_SEVERITY INT
DECLARE @ERR_STATE INT
-- set variables through built in methods
SELECT @ERR_MSG=ERROR_MESSAGE()
,@ERR_SEVERITY=ERROR_SEVERITY()
,@ERR_STATE=ERROR_STATE();
-- RE- raise error back to calling application
RAISERROR (@ERR_MSG,@ERR_SEVERITY,@ERR_STATE);
RETURN 0
END CATCH
END
Amir Naraghi anaraghi@verizon.net Page 18 of 34
19. SetFocus Project # 4 (Library Phase III) - .Net Framework
Objective:
To convert the existing Library Application into a Web Application, this incorporates the same user
functionality as the previous windows form application.
Summary:
This project demonstrated the use of ASP .NET. Some of the techniques highlighted in the project were:
Use of Master Pages and Themes Forms-based authorization and
Use of Cascading Stylesheet (CSS) authentication
AJAX Controls for partial postback Use of ASP .NET Membership and Roles
Use of menu controls ASP .NET Configuration Manager
Use of Login Controls Manipulation of web.config
Description:
The success of the windows based Library Management Tool
application and the growing popularity of web based application lead
to a decision of converting the windows application into its web-
based counterpart. The application would continue to support the
existing functionality and also incorporate additional functionality to
support the needs of the client.
The current system did not have any means to detect and update an
expired membership. In order to support the client the membership
page was fitted so that when an expired member was detected the
librarian was given a choice to renew the membership.
In order to make the application act as though it was a window based
application I integrated server side AJAX controls. I also used menu
control to give a similar look and feel of the existing Management
Tool. To keep look and feel of the application sharp and user friendly I
used a Master Page, Theme, and a Cascading Stylesheet. Security
measures have also been implemented in the design in the form of Forms-based authorization and
authentication. A Librarian administrator role and users have been added using ASP .NET’s default
security services.
Amir Naraghi anaraghi@verizon.net Page 19 of 34
20. SetFocus Project # 4 (Library Phase III) - .Net Framework
Library Operations and Rules (Added functionality):
Membership/Roles:
Set authentication to Forms
Added Librarian Role and users
Set authorization to only allow access to Librarian Role
Member Information:
When an expired member is detected the Librarian is given an option to renew the
membership. Until the membership is renewed, the checkout item button remains
disabled.
Project Screen Captures:
Library Splash Screen
Amir Naraghi anaraghi@verizon.net Page 20 of 34
21. SetFocus Project # 4 (Library Phase III) - .Net Framework
Project Screen Captures:
Library Log In Page
Library Member Information Page
Amir Naraghi anaraghi@verizon.net Page 21 of 34
22. SetFocus Project # 4 (Library Phase III) - .Net Framework
Project Screen Captures:
Library Member Information Page (Member Lookup)
Amir Naraghi anaraghi@verizon.net Page 22 of 34
29. SetFocus Project # 4 (Library Phase III) - .Net Framework
Project Code Sample:
Member Information Source Code (AJAX Update Panel on Grid View)
Amir Naraghi anaraghi@verizon.net Page 29 of 34
30. SetFocus Project # 4 (Library Phase III) - .Net Framework
Project Code Sample:
Member Information Retrieve Member Information
Amir Naraghi anaraghi@verizon.net Page 30 of 34
31. SetFocus Project # 5 (Library Phase IV) - .Net Framework
Objective:
To convert existing Library Management Entities, Data Access, and Business Layer to be used in a WCF
service in order to support interoperability with other systems.
Summary:
This project demonstrated the use of Windows Communication Foundation (WCF). Some of the
techniques highlighted in the project were:
WCF Service Library Project Use of Principal Permissions to secure
WCF Service Website Project service operations
Authentication using ASP .NET Membership Use of Data Contracts on Entities
Authorization using ASP .NET Roles Setup of service to run off IIS using SSL
Custom Fault Exception Class
Description:
With the successful role out of the library system and the potential to acquire additional libraries and
partnerships I have been tasked with converting the exiting layers into a WCF service. This will allow for
interoperability with other systems. The Entities layer was modified to use DataContracts. The service
used WSHttpBinding, and authentication and authorization were provided through ASP .NET
membership and roles.
The Business Layer did not change; it was simply called by the service. The presentation layer called the
service and all references to business layer were removed. Since passing by reference was not
supported certain methods such as add member were modified in the service implementation to return
the member back. I used a strongly typed fault exception in order to pass back any exception that may
have occurred during the transaction between the presentation and service. This allowed me to use the
existing Library Exception class created in the previous phase, but pass it back to the presentation layer
as a strongly typed fault exception. Therefore the presentation layer did not require much modification
when it came to error handling.
The service was then hosted using SSL. I used a self-generated certificate so that I could setup the
service under IIS. This was purely for development purposes under a business rollout a certificate would
have to be purchased and setup.
Amir Naraghi anaraghi@verizon.net Page 31 of 34
32. SetFocus Project # 4 (Library Phase IV) - .Net Framework
Project Code Sample:
Library Service Contract
Amir Naraghi anaraghi@verizon.net Page 32 of 34
33. SetFocus Project # 4 (Library Phase IV) - .Net Framework
Project Code Samples:
Library Service Class
Amir Naraghi anaraghi@verizon.net Page 33 of 34