Skip to content

This repository can be used to create a simple back-end for an online marketplace. Coded in C#, using Swagger and MongoDB for persistent storage.

Notifications You must be signed in to change notification settings

wickertongue/code_test_csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Code Test C#

Task: To creating a simple back-end for an online marketplace

This repository can be used to create a simple back-end for an online marketplace. Coded in C#, using Swagger and MongoDB for persistent storage.

Getting Started

Installation

Create Mongo Database

Create a database using MongoDB within the terminal.

  1. Open Mongo by typing mongo into the terminal
  2. Create a database called Inventory by entering use Inventory
  3. Create a table called Products by entering db.createCollection("Products")
  4. Optional - seed the database using the following:
db.Products.insertMany(
	[
		{'Name':'Lavender heart', 'Price':925}, 
		{'Name':'Personalised cufflinks', 'Price':4500}, 
		{'Name':'Kids T-shirt', 'Price':1995}
	]
)

Visual Studio

Install the following packages to ensure the code compiles:

  1. Microsoft.Api (v.1.1.4)
  2. Microsoft.VisualStudio.Web.CodeGeneration.Design (v.3.0.0)
  3. MongoDB.Driver (v.2.9.3)
  4. Swashbuckle.AspNetCore.SwaggerGen (v.5.0.0-rc4)
  5. Swashbuckle.AspNetCore.SwaggerUI (v.5.0.0-rc4)
    • With Swagger, it is particularly important to be on version 5, as older versions of Swagger will throw conversion errors on compile.

Run Build

Build and run and a browser window should open automatically to https://localhost:[port]/product and show all products stored.

Visiting https://localhost:[port]/swagger/index.html will provide you with a list of endroutes.

Future Developments

  • Remove MongoDB and replace with MySQL / Postgres to allow for relational database mapping (also achievable through Mongoose with MongoDB, but I'm biased towards SQL).
  • Product codes as autogenerated unique ids would be easier to manage in a SQL database, as MongoDB generates large ids.

About

This repository can be used to create a simple back-end for an online marketplace. Coded in C#, using Swagger and MongoDB for persistent storage.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages