0% found this document useful (0 votes)
85 views32 pages

And Authentication Using Facebook Oauth2.0: A Thesis Is Submitted To The Department of

The document describes a thesis submitted by Shuvankar Pati for a Bachelor of Technology degree. The thesis proposes developing an online hotel reservation application using .NET MVC and Facebook OAuth 2.0 authentication. The application will allow booking tables, billing, and displaying guest details. The document includes sections on introduction, database design, authentication implementation, code snippets, and a conclusion.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views32 pages

And Authentication Using Facebook Oauth2.0: A Thesis Is Submitted To The Department of

The document describes a thesis submitted by Shuvankar Pati for a Bachelor of Technology degree. The thesis proposes developing an online hotel reservation application using .NET MVC and Facebook OAuth 2.0 authentication. The application will allow booking tables, billing, and displaying guest details. The document includes sections on introduction, database design, authentication implementation, code snippets, and a conclusion.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Online Hotel Reservation App using .

Net MVC
and Authentication using Facebook Oauth2.0

A thesis is submitted to the department of

Information Technology
Of
International Institute of Information Technology Bhubaneswar
in partial fulfilment of the requirements for the degree of

Bachelor of Technology
by

Shuvankar Pati
(Roll- B416047)
under the supervision of
Prof. Dr SriChandan Sobha Nayak
CSE

International Institute of Information Technology Bhubaneswar


Bhubaneswar Odisha - 751003, India 2020
May 24, 2020
Undertaking
I declare that the work presented in this thesis titled Online Hotel
Reservation App using .Net MVC , submitted to the Department of CSE,
International Institute of Information Technology, Bhubaneswar, for the award of
the Bachelors of Technology degree in the CSE, is my original work. I have not
plagiarised or submitted the same work for the award of any other degree. In case
this undertaking is found incorrect, I accept that my degree may be
unconditionally withdrawn.

Shuvankar Pati
B416047
May 24, 2020

Certificate
This is to certify that the work in the thesis entitled Title of your Thesis by
Your Name is a record of an original research work carried out by him
under my supervision and guidance in partial fulfilment of the requirements
for the award of the degree of Bachelor of Technology in branch name.
Neither this thesis nor any part of it has been submitted for any degree or
academic award elsewhere.

Dr Srichandan Sobha Nayak


Acknowledgment
The elation and gratification of this seminar will be incomplete without
mentioning all the people who helped me to make it possible, whose
gratitude and encouragement were invaluable to me. I would like to thank
God, almighty, our supreme guide, for bestowing is blessings upon me in
my entire endeavor. I express my sincere gratitude to Prof. Dr Srichandan
Sobha Nayak, for his guidance and support and students of my class for
their support and suggestions.
Shuvankar Pati
Abstract
Nowadays everything is doable over online platform,thus bringing the world too
closer.We must have surely seen online delivery partners,online cabs,online
reservation of tickets etc.In view of all these,I worked on a project of building an
online Hotel Rerservation system using MVC and further used facebook
authentication using Oauth 2.0 to make it secure against unauthorized access.In
these web application there are three functionalities,Booking table,Billing and
displaying data in a sorted format.For this I used .net framework and created a
mvc project,created only one table and used the status keyword which simplified
the entity relationship.there are two tables,guest and reservation.the status key
has been used to denote whether a particular table is booked or not.We have
separate views in respective controllers to implement the functionalities.I have
used dropdowns and proper model binding in order to access the entities through
the model state.I have also used proper exception handling using tempdata and
paved way for implementation of bootstrap modal popups to enhance the UI.
Keywords:
 MVC
 Oauth
 Controller and views(partial views)
 Tempdata
Contents
Abstract v
1 Introduction 1
1.0.1 Asp.Net MVC . . . . . . . . . . . . . . . . . . . . . . . . 2
1.0.2 Life cycle of MVC . . . . . . . . . . . . . . . . . . . . . . . . 3
1.0.3 ViewData,ViewBag and TempData . . . . . . . . 4
1.0.4 Controllers Actions and Views . . . . . . . . . 6
1.1 Solution Explorer and N Layer Structure . . . . . . . . . . . . . 7
1.2 Work flow model through model-view-controller . . . . 9
1.3.1 Landing Page Layout. . . . . 12
1.3.2 Booking table by reservationId . . . . . . . . .. 16
1.3.3Billing and updating details in database. . . . 18
1.4 Displaying guest details using interfaces . . . . 20
2 Database and entity relation . . . . . . . . . . . . . . . . . . . . . .20-23

3 Authentication and authorization(Facebook Oauth 2.0) 24-27


4 Important Code snippets with Logic 28-30

5 Conclusion and further implementations 30-31


Introduction
The Online hotel reservation web application is a system where we inculcate the
real sceniarios of the table booking system in Barbeque Nation.We have a certain
number of table to which I have provided separate table id’s and accordingly
booked and updated in database.Another parameter I have taken is number of
persons,as in a restaurant we have respective tables for number of peoples
count,so here I have applied the respective validation using javascript and regex
for ensuring the booking is done for right number of people.In the next part I
have a form where the guest details are entered and the admin is entering the
table id for the billing process.Based on veg or non-veg buffey Rs 599 or Rs 699
are assigned.After the billing is done,the status of the booking table is changed to
‘0’ meaning its free to book .All the database interactions are done with ADO.Net
framework and stored procedures.Furthermore the next part is to know the
status and its vital for the admin for further proceedings,so I have 4 functionalities
like displaying the guest details in a sorted form of their booking Id,displaying the
Guest details who have left the restaurant ,here for those who have successfully
billed,I have stored their details in a separate list and retrieved,the next two are
displaying the guest details based on their bill amount.(Bill amount = Bill per
person * No of guests).I have secured this web app by using facebook
authentication using Oauth 2.0 which gives access to those users who are logged
in through facebook platform.
ASP.Net MVC
ASP.NET is a free web framework for building websites and web applications
on .NET Framework using HTML, CSS, and JavaScript.

ASP.NET MVC 5 is a web framework based on Mode-View-Controller (MVC)


architecture. Developers can build dynamic web applications using ASP.NET
MVC framework that enables a clean separation of concerns, fast
development, and TDD friendly.

MVC stands for Model, View, and Controller. MVC separates an application into
three components - Model, View, and Controller.

Model: Model represents the shape of the data. A class in C# is used to


describe a model. Model objects store data retrieved from the database.

Model represents the data.

View: View in MVC is a user interface. View display model data to the user
and also enables them to modify them. View in ASP.NET MVC is HTML, CSS,
and some special syntax (Razor syntax) that makes it easy to communicate
with the model and the controller.

View is the User Interface.

Controller: The controller handles the user request. Typically, the user uses
the view and raises an HTTP request, which will be handled by the controller.
The controller processes the request and returns the appropriate view as a
response.

Controller is the request handler.


MVC Life Cycle
At a high level, a life cycle is simply a series of steps or events used to
handle some type of request or to change an application state.
MVC has two life cycles −

 The application life cycle


 The request life cycle

The Application Life Cycle


The application life cycle refers to the time at which the application process actually
begins running IIS until the time it stops. This is marked by the application start and
end events in the startup file of your application.

The Request Life Cycle


It is the sequence of events that happen every time an HTTP request is handled by our
application.
The entry point for every MVC application begins with routing. After the ASP.NET
platform has received a request, it figures out how it should be handled through the
URL Routing Module.
Modules are .NET components that can hook into the application life cycle and add
functionality. The routing module is responsible for matching the incoming URL to
routes that we define in our application.
All routes have an associated route handler with them and this is the entry point to the
MVC framework.

The MVC framework handles converting the route data into a concrete controller that
can handle requests. After the controller has been created, the next major step
is Action Execution. A component called the action invoker finds and selects an
appropriate Action method to invoke the controller.
After our action result has been prepared, the next stage triggers, which is Result
Execution. MVC separates declaring the result from executing the result. If the result
is a view type, the View Engine will be called and it's responsible for finding and
rending our view.
If the result is not a view, the action result will execute on its own. This Result
Execution is what generates an actual response to the original HTTP request.
ViewBag,ViewData and TempData
ViewBag, ViewData, and TempData all are objects in ASP.NET MVC and these are
used to pass the data in various scenarios.

The following are the scenarios where we can use these objects.

1. Pass the data from Controller to View.


2. Pass the data from one action to another action in the same Controller.
3. Pass the data in between Controllers.
4. Pass the data between consecutive requests.

ViewBag

ViewBag is a dynamic object to pass the data from Controller to View. And, this will
pass the data as a property of object ViewBag. And we have no need to typecast to
read the data or for null checking. The scope of ViewBag is permitted to the current
request and the value of ViewBag will become null while redirecting.
 
ViewData

ViewData is a dictionary object to pass the data from Controller to View where data is
passed in the form of key-value pair. And typecasting is required to read the data in
View if the data is complex and we need to ensure null check to avoid null exceptions.
The scope of ViewData is similar to ViewBag and it is restricted to the current request
and the value of ViewData will become null while redirecting.
 
TempData

TempData is a dictionary object to pass the data from one action to other action in the
same Controller or different Controllers. Usually, TempData object will be stored in a
session object. Tempdata is also required to typecast and for null checking before
reading data from it. TempData scope is limited to the next request and if we want
Tempdata to be available even further, we should use Keep and peek.
Controller Actions and Views
What is a Controller
In ASP.NET MVC, a Controller is used to define and group a set of actions.
An action (or action method) is a method on a controller that handles incoming
requests. Controllers provide a logical means of grouping similar actions together,
allowing common sets of rules (e.g. routing, caching, authorization) to be applied
collectively. Incoming requests are mapped to actions through routing.

In ASP.NET Core MVC, a controller can be any instantiable class that ends in
“Controller” or inherits from a class that ends with “Controller”. Controllers should follow
the Explicit Dependencies Principle and request any dependencies their actions require
through their constructor using  dependency injections.

Defining Actions
Any public method on a controller type is an action. Parameters on actions are bound to
request data and validated using model binding.

Action methods should contain logic for mapping an incoming request to a business
concern. Business concerns should typically be represented as services that your
controller accesses through dependency injection. Actions then map the result of the
business action to an application state.

What are views?


In the Model-View-Controller (MVC) pattern, the view handles the app's data
presentation and user interaction. A view is an HTML template with embedded Razor
Markup. Razor markup is code that interacts with HTML markup to produce a webpage
that's sent to the client.

In ASP.NET Core MVC, views are .cshtml files that use the C# Language  in Razor
markup.
Solution Explorer and N Layer Structure
The following is my Web app’s Solution explorer structure:
This is my Controller view in which account controller works for authentication
and user controller is for restaurant app purpose.
The corresponding views are:
As you can see the Web config file has all the essential database connection
strings and configuration settings.
Controller and their views

This is the layout page(landing page).

Reservation Table Page


Booking View using bootstrap Forms and modals.
Handled Exceptions If the Guest Id is not present in
the database.
Displaying results based on Reservationid using
icomparable.
Entities and Interfaces(Icomparable and Icomparer)
There are two entities:
1.Reservation
2.Guest
Interfaces

Here I have used icomparer and icomparable to sort based on


reservation and guest id’s respectively.
Database
As from the above diagram we can see the respective primary keys of the two
tables. Here I used Reservation Id as the foreign key in Guest table and as
mentioned earlier the status variable which takes 0 or 1 based on the booking.
Authentication using Facebook OAuth2.0

In this process I took help of online documentation and created an app using
facebook developers and deployed it in my web app.I was given a secret id and
secret authentication id for using it in my web app.I also used AllowAnnonymous
keyword data annotation for authorizing the web app based on the roles.

Account Controller
Now I will show you the process or control flow:
As you can see its already logged in. So I logged out and then redirected to
login page in facebook and then got authenticated.
Important Code Snippets
Conclusion and Further Implementation
The web application is working fine from end to end and was reviewed by my
training project camp lead.I was asked to use entity framework and implement
the same using web api and mvc by using jquery and ajax by consuming the web
api requests.This app can be used to facilitate the concept of online booking and
reserving hotel table,it was dynamically being updated based on adding billing
details and also displaying the no of persons left and the no of persons who are
still in the restaurant.It can further be improved by adding Menu,dishes,timing
etc.Iam working on it in this holiday break.

References
https://www.tutlane.com/tutorial/aspnet-mvc/oauth-facebook-login-for-asp-net-
mvc-website-with-example (for facebook auth)
https://docs.microsoft.com/en-us/aspnet/mvc/overview/security/create-an-
aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on
https://www.w3schools.com/bootstrap/bootstrap_modal.asp
(for bootstrap modals)

You might also like