Skip to content

Acme Corporation - Users can enter a draw for a prize.

License

Notifications You must be signed in to change notification settings

Flakvard/ASP.NET-website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

Introduction

What is this project about?

The landing page is for an international company called “Acme Corporation” where users can enter a draw for a prize.

A user can enter the draw if they have a valid serial number from purchasing one of Acme Corporation’s products.

You can test the valid product serial number in the ~/ASP.NET-website/"Product serial numbers.txt" file.

The valid product serial number can be used twice in the draw, but the user must fill out a form and be at least 18 years old.

Getting started

Clone repo

Clone via PowerShell.

git clone https://github.com/Flakvard/ASP.NET-website.git

Open path in File Explorer.

cd ASP.NET-website/AcmeCorporation && explorer .

And then open AcmeCorporation.sln via Visual Studio.

Database setup

Inside appsettings.json there is the default login. No username or password needed, but be sure to add the database to a working Server=<server>. MSSQL Management studio you can find relevant information about this.

  "ConnectionStrings": {
    "DefaultConnection": "Server=LAPTOP-AV3K8LV5;Database=AcmeCorp;Trusted_Connection=True;TrustServerCertificate=True;"

There are already 100 valid serial numbers generated via Add-Migration, so you only need to Update-Database inside the Package Manager Console in Visual Studio like this:

PM> Update-Database

Implementation

The aim was to try an create an flexible, maintainable, and testable system that can adapt to changing requirements over time.

This was done by:

  • Defining the layers of the project
  • Try to hold SOLID principles on all levels to improve modularity and testability.
  • Test everything
  • Implementing Inversion of Control (IoC) using Dependency Injection (DI) between the layers/components.
  • Using EntityFramework ORM for the Data layer/repository

There is of course other ways to do this, and I could add more abstractions layers, but I did not think it was neccesery for the assignment.

I tried my best to hold the YAGNI principles and not go by "ifs/maybes".

Assignment:

  • Using Visual Studio
  • Create a web application project
  • Create secondary projects for
    • test
    • class library content
  • Create database and table(s) to store information for the draw
  • README.md steps to get the database running locally
  • Generate 100 valid serial numbers
    • Export the generated serial numbers for submitting ("~/Product serial numbers.txt")
  • Create a submission form on a web page (should include):
    • First name
    • Last name
    • Email address
    • Product serial number
    • Over 18 (Yes/no) (My addition to the form)
  • Form submission data needs to be:
    • validated and
    • stored in the database
    • Both client-side and server-side validation on user input. (My addition to the form)
  • Create a web page showing all the form submissions
    • Pagination showing 10 items per page
  • Write unit tests for validating the form data to ensure that the rules for entering the draw are followed

Bonus:

  • Use IoC/Dependency Injection for the solution
    • Dependency Injection into ASP.NET WebApplication pipeline builder
      • IDrawManager
      • IApplicationDbContext
  • Unit test for the Controller action submitting the form
    • Serverside validation with invalid and valid
    • Get submissions via Async and JSON (for AJAX)
  • Display submissions via AJAX GET method
  • Notification of successful form submission
  • Write a README.md file at the root of your repository
  • Require authenticated access to view the report of form submissions

Structure

This website is created using ASP.NET in Visual Studio's solutions - AcmeCorporation. There are three projects in the solution: AcmeCorporationWebsite, AcmeCorporationLibrary and AcmeCorporationUnitTests

AcmeCorporationLibrary (Class Library Project):

└── AcmeCorporationLibrary
    ├── AcmeCorporationLibrary.csproj
    ├── Business
    │   ├── DrawManager.cs
    │   └── IDrawManager.cs
    ├── Data
    │   ├── ApplicationDbContext.cs
    │   └── IApplicationDbContext.cs
    ├── Migrations
    │   └── ApplicationDbContextModelSnapshot.cs
    └── Models
       ├── ErrorViewModel.cs
       ├── SerialNumberModel.cs
       └── SubmissionModel.cs

AcmeCorporationWebsite (ASP.NET Web Application Project):

└── AcmeCorporationWebsite
    ├── AcmeCorporationWebsite.csproj
    ├── Controllers
    │   ├── HomeController.cs
    │   └── SubmissionController.cs
    ├── Views
    │   ├── Home
    │   │   ├── Index.cshtml
    │   │   └── Privacy.cshtml
    │   ├── Shared
    │   │   ├── _Notification.cshtml
    │   │   └── _ValidationScriptsPartial.cshtml
    │   └── Submission
    │       ├── Index.cshtml
    │       └── SubmitForm.cshtml
    ├── appsettings.Development.json
    ├── appsettings.json
    └── wwwroot
        ├── css
        │   └── bootswatchTheme.css
        ├── js
        │   └── submission.js
        └── lib
            └── ...

AcmeCorporationUnitTests (Testing Project):

└── AcmeCorporationUnitTests
    ├── AcmeCorporationUnitTests.csproj
    ├── Business
    │   └── DrawManagerUnitTest.cs
    ├── Controller
    │   └── SubmissionControllerUnitTest.cs
    ├── Data
    │   └── ApplicationDbContextUnitTest.cs
    ├── GlobalUsings.cs
    └── Models
        ├── SerialNumberModelUnitTest.cs
        └── SubmissionModelUnitTest.cs

About

Acme Corporation - Users can enter a draw for a prize.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published