EASTERN INTERNATIONAL UNIVERSITY Practice Assignment – Quarter 1, 2024-2025
SCHOOL OF COMPUTING AND Course Name: .Net Programming
INFORMATION TECHNOLOGY Course Code: CSE 443
Student’s Full Name:
Student ID:
Practice Assignment 4
LIBRARY MANAGEMENT SYSTEM
Following Practice Assignment 3, further develop the new layout and add model in the
MVC framework
------------------------------------------------------------------------------------------------------------
Exercise 1: Create a admin layout for library management system.
In Practice Assignment 3, there is a menu in area 1 in “Figure1”. Add one item to that menu
named 'Admin.' When clicking on the admin menu, it should navigate to the admin layout,
which is basically similar to the following image:
Figure 1: Admin layout
Requirements:
Initialize sample data to display the menu.
When selecting any item in the menu, it should navigate to the corresponding
screen and render the content.
Prepare sample data to be displayed on the interface.
Exercise 2:
Design a database using SQL Server and migrate it to the model in the MVC project
with the tables listed below.
Figure 2: Diagram of the library management database
Users:
User
# Col_Name Data Type Descriptions
Unique identifier for each user,
1 UserId int
auto-incremented.
2 Fullname nvarchar(200) Full name of the user.
Additional info about the user, like
3 Description nvarchar(MAX)
interests or bio.
Hashed password for secure
4 Password nvarchar(MAX)
authentication.
User's email address, used for
5 Email nvarchar(100)
communication and verification.
6 Phone nvarchar(20) User's contact phone number.
User's physical address for mailing
7 Address nvarchar(MAX)
or location purposes.
8 Status int Represents the user's status.
Date and time when the user
9 CreatedDate datetime
account was created.
Unique code for internal
10 UserCode nvarchar(MAX)
identification of the user.
Indicates if the account is locked
11 IsLocked bit
(1) or active (0).
Marks the account as deleted (1) or
12 IsDeleted bit
active (0) for soft deletion.
Shows if the account is active (1) or
13 IsActive bit
inactive (0).
Code for account activation, sent
14 ActiveCode nvarchar(MAX)
via email during registration.
Avatar’s User - Local location in
15 Avatar nvarchar(MAX)
the server to get the picture.
Loans:
Loans
Data
# Col_Name Descriptions
Type
1 LoanId int (Primary Key, Auto-Increment)
2 UserId int References the user who borrowed the book.
3 BookId int References the borrowed book.
4 LoanDate datetime Date when the book was borrowed.
5 DueDate datetime Date when the book is due.
6 ReturnDate datetime Date when the book was returned.
Status of the loan (e.g., "Active", "Returned",
7 Status int "Overdue"). 0: Active , 1: Returned , 2:
Overdue
Books:
Books
# Col_Name Data Type Descriptions
1 BookId int (Primary Key, Auto-Increment)
2 Title nvarchar(200) Title of the book.
3 Description nvarchar(MAX) Description of the book.
4 BookCode nvarchar(MAX) Standard Book Number.
5 Publisher nvarchar(MAX)
6 PublishedYear datetime Year the book was published.
7 CategoryId int References the category.
8 AuthorId int References the author.
Total number of physical
9 TotalCopies int copies of the book in the
library
Total number of physical
copies of the book currently in
10 AvailableCopies int
the library, excluding copies on
loan
Date when the book record was
11 CreatedDate datetime
created.
Cover image of the book -
12 Avatar nvarchar(MAX) Local location in the server to
get the picture.
Store the version pdf for
13 Pdf nvarchar(MAX)
reading online
Authors:
Authors
# Col_Name Data Type Descriptions
(Primary Key, Auto-Increment).
1 AuthorId int
Unique identifier for each author.
2 FirstName nvarchar(100) Author's first name.
3 LastName nvarchar(100) Author's last name.
4 DateOfBirth datetime Author's date of birth.
5 Biography nvarchar(MAX) A short biography of the author.
6 Nationality nvarchar(100) Nationality of the author.
7 Email nvarchar(100) Author's Email.
8 Website nvarchar(100) Author's Website.
Date when the author record was
9 CreatedDate datetime
created.
The IsActive column helps indicate
10 IsActive bit whether a record is currently active
and usable within the application.
Authors’ Avatar - Local location in
11 Avatar nvarchar(MAX)
the server to get the picture.
Categorys:
Categorys
# Col_Name Data Type Descriptions
Unique identifier for each category
1 CategoryId int
(Primary Key).
Name of the category; must be
2 Name nvarchar(MAX)
unique for identification.
Additional information about the
3 Description nvarchar(MAX)
category.
Date and time when the category
4 CreatedDate datetime
was created.
Date and time when the category
5 UpdatedDate datetime
was last updated.
Indicates if the category is active (1)
6 IsActive bit
or inactive (0).
Categorys’s image - Local location
7 Avatar nvarchar(MAX)
in the server to get the picture.
Note:
Use Data Annotations for Validation:
Implement data annotations such as [Required], [StringLength],
[EmailAddress], etc., to enforce validation rules on model properties.
Ensure that validation attributes reflect business rules and requirements.
Implement Navigation Properties:
Define relationships between models using navigation properties (e.g., one-to-
many, many-to-many).
Use collections to represent related entities (e.g., ICollection<Product> in a
Category model).
Create a DbContext Class:
Define a DbContext class that represents the session with the database.
Include DbSet<T> properties for each model to facilitate data access.
Exercise 3:
Add a new table “Carousel” and make a model in project for displaying images or content
on the homepage of your library management system with the following requirements:
Purpose:
Display images or promotional content on the homepage.
Fields:
CarouselId: int (Primary Key)
ImageUrl: nvarchar(MAX) (Required) - URL of the image.
Title: nvarchar(200) (Required) - Title for the item.
Description: nvarchar(MAX) (Optional) - Additional details.
LinkUrl: nvarchar(MAX) (Optional) - URL linked to the item.
Order: int (Required) - Display order of items.
IsActive: bit - Indicates if the item is active.
CreatedDate: datetime - Timestamp of creation.
UpdatedDate: datetime - Timestamp of last update.
In Practice Assignment 3, the Carousel currently loads static data. With this table,
implement the business logic and load data dynamically from the database.
Guide:
To serve image files from the server in your .NET Core 8.0 MVC project, you can
configure your application to serve static files from a specific directory on the server.
Here’s how to set it up:
Step 1: Store Images in a Server Directory
1. Decide on a directory where you’ll store the images for the carousel. For example,
let’s use a folder named carousel_images inside the wwwroot folder of your
project (e.g., wwwroot/carousel_images).
2. Place your image files in this directory.
* You can set anywhere in the server if you want to store the image !
Step 2: Configure Static Files in Startup or Program.cs
In ASP.NET Core 8.0, static files are served by default from the wwwroot folder. You
just need to make sure the UseStaticFiles middleware is added to your pipeline, which is
typically already included.
In your Program.cs, you should have:
Step 3: Update the Model to Use Server Path for Images
In the Carousel model, set the ImageUrl to store relative paths, such as
/carousel_images/image1.jpg.
Step 4: Display the Image in the Carousel View
1. In the _Carousel.cshtml partial view, ensure the src attribute of the <img> tag is
set to the relative path stored in ImageUrl.
Step 5: Access Images from the Server
When you run your application, ASP.NET Core will serve images directly from the
wwwroot directory. So if your ImageUrl is /carousel_images/image1.jpg, it will be
resolved to https://yourdomain.com/carousel_images/image1.jpg.