Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

codeinclined/Labb11-Intro-to-MVC

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PersonOfTheYear

Author: Joshua Taylor Version: 1.0.0

Overview

PersonOfTheYear is a demonstration of the MVC architecture in ASP.NET Core. It provides a simple form using a Razor View asking for a minimum year and a maximum year. Submitting this form results in a HTTP POST which redirects the user to a results page containing all of the person of the year entries within the specified years (inclusive) taken from a CSV source.

Getting Started

PersonOfTheYear targets the .NET Core 2.0 platform. The .NET Core 2.0 SDK can be downloaded from the following URL for Windows, Linux, and macOS:

https://www.microsoft.com/net/download/

The dotnet CLI utility would then be used to build and run the application:

cd LinqInManhattan
dotnet build
dotnet run

The dotnet run command will start an HTTP server on localhost using Kestrel which can be accessed by the user's browser pointing to localhost on the port provided by dotnet run's console output.

Additionally, users can build and run PersonOfTheYear using Visual Studio 2017 or greater by opening the solution file at the root of this repository. Unit tests have been provided for only the CSV parsing code and make use of the xUnit testing framework (included via a NuGet dependency).

Example

Index View for the Home Controller

Index View Screenshot

Results View Using Input From the Index View

Results View Screenshot

Results View With No Results

No Results View Screenshot

Architecture

PersonOfTheYear consists of a single MVC controller, HomeController, with two actions, Index and Results.

HomeController

HomeController defines two actions for the PersonOfTheYear application. Each action is associated with its own Razor View page detailed below. StaticFiles is used in conjunction with MVC in order to deliver the CSS3 style sheet for both Razor Views and the background image displayed in those views.

Index (Razor View and Action)

Index delivers the user a simple HTML form asking for a minimum and maximum year from which Person of the Year awardees will be filtered in the Results view. These years are input via HTML input tags and delivered to the Home controller via HTTP POST.

Results (Razor View and Action)

Results displays a listing of Time Person of the Year awardees within the range of years specified by the user using the Index action from HTTP POST. All rows of the source data are displayed in an HTML table using Razor syntax to retrieve values from the data model.

Data Model (Person)

The data model is composed of a single Person class which contains properties for Year, Honor, Name, Country, Birth Year, Death Year, Title, Category, and Context. These values are populated by an included CSV file and placed into a .NET generic List object by the Results action upon redirect from the Index action's POST implementation. No manipulation of the source CSV file is performed beyond reading from the file.

Change Log

  • 4.3.2018 Joshua Taylor - Initial release. All included tests are passing.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 88.4%
  • CSS 11.6%