Skip to content

Build applications using csharp and asp dotnet

Mikael Roos edited this page Mar 20, 2020 · 8 revisions

This is the assignment A07 for "Section 07: ASP.NET and Model View Controller (MVC)".

You should save your work in work/s07/console and work/s07/webapp.

Prerequisites

You have worked though the following articles.

You have visited the lectures to get a brief introduction to the following techniques.

  • .NET Core development environment
  • C# programming language
  • ASP.NET Core framework for web applications

Information

Start by copying example/dotnet/data to your work/ directory. It contains JSON data that you shall use. The JSON data represents bank accounts.

You should create one console application in work/s07/console. You should use .NET Core and C#.

You should create one webapp application in work/s07/webapp. You should use .NET Core, ASP.NET Core, C# and the MVC architectural design pattern.

A pretty formatted text table, in the console app, could look like this.

+--------+---------+-----------+-------+
| Number | Balance |   Label   | Owner |
+--------+---------+-----------+-------+
| 111111 |       0 | Salary    | 11    |
+--------+---------+-----------+-------+

You may restructure or update your JSON file.

Requirements grade 3

  1. console

    1. Create a menu driven console application with the menu choices.
    2. The user should select what to do and the application should close when the user selects "Exit" from the menu.
    3. The choice "View accounts" should load the accounts from the JSON file and print out a pretty formatted text table with a header and details of all accounts.
    4. The choice "View account by number" should ask the user for an id and show the account that matches that id.
  2. webapp

    1. Create a web application that uses your account database.
    2. Create a page to your application, name it "About" and put some basic text in it, describing this exercise.
    3. In the Home page, generate a HTML table of all accounts, read data from the json file. Use a Model class for Account and a Service class for the json file reader.
    4. Add a controller that provides a json response with all accounts, add it to the path api/accounts.
    5. Add a controller, to handle the route api/account/<number> which shows the account details for that particular account. For example, the path api/account/111111 show a json response with all details on that account. Proved an error message, as json, when the account number does not exists.
    6. Update the navigation and add links to all your pages and routes.

Requirements grade 4

  1. Do all requirements for grade 3.

  2. console

    1. Add a choice "Search" that ask the user for a search string. Show all accounts that matches that searchstring by its number, full or substring match of label or by its owner.
    2. Add a choice "move" that moves money (balance) from one account number to another account number. Save the updated JSON file.
  3. webapp

    1. Add a controller that supports moving between two accounts. You may choose to solve this using the rest api or through a html form. Use a POST or PUT method. GET is not the prefered way when updating the state of the web application.

Requirements grade 5

  1. Do all requirements for grade 4.

  2. console

    1. Add a choice "New account" that creates a new account. Ask the user for account details. Save the updated JSON file.
    2. Organise your code in at least one external class in its own file.
  3. webapp

    1. Make it possible to move money between accounts using both a HTML post form and through the JSON REST API. Use controllers and models to separate your code and use Razor for the html form pages. Use POST and PUT as request method.
    2. Ensure you are reusing your code, avoid duplicate code.