Skip to content

RainDance74/ShopOfPryaniks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The task:

Implement a service that supports JSON-message exchange to provide information about the list of products in the virtual store, as well as the ability to form an order, remove an item from the list of available items or cancel the order by the user.

As a database you can use a static object in asp.net controller or any relational DBMS you know. As a client you can use any tool for sending and receiving requests. for example: Postman, Insomnia or Restlet plugin for Chrome.

At a minimum, the application should implement the "Product" and "Order" classes, and methods for working with instances of these classes:

  • adding a new item to the list of items available for ordering
  • removing an item from the list of items available for ordering
  • viewing the list of goods available for ordering
  • creating an order for a product (one or several)
  • cancel (delete) an order
  • viewing the list of orders for a user

Adding something else to any of the tasks is not prohibited, but can be both a plus (if it is implemented well and does not break out of the internal logic) and a minus (if it creates a problem and/or is not thought out). The main interest is in the internal logic (developer's understanding of the purpose of all parts of his code) and stable operation of the application (ability to handle errors and respond to unexpected / incorrect requests)

Launching the Application

Prerequisites:

  • A configured PostgreSQL database.
  • A connection string to the database, provided either through an environment variable or in the appsettings.json file located at src/Web/appsettings.json. Specify the connection string as the value for DefaultConnection.

Steps:

  1. Launch the solution:
  • Use CLI commands or Visual Studio to launch the solution.
  • No configuration for HTTPS is needed, so you can disregard SSL certificates.
  1. View the application address:
  • Once the Web project profile "http" is launched, the application's address will be displayed in the console.

Application Features

This API offers the following functionalities:

  • Order creation: Create orders from your cart.
  • Product management: Perform CRUD (Create, Read, Update, Delete) operations on products.
  • Cart management: Add, remove, and manage items in your cart.

Usage

  1. Access the API:
  • Send HTTP requests to the API address displayed in the console.
  • Note: Unauthenticated users can only view the list of products.
  1. Authentication (Optional):
  • To perform product editing or other actions requiring authorization, log in using the default administrator credentials:
  • Login: admin@localhost
  • Password: admin1
  • Successful login will provide a Bearer token, which must be included in subsequent authenticated requests.
  • Alternatively, create a non-administrator account for regular usage.
  1. Product Interaction:
  • View the list of products.
  • Add products to your cart.
  1. Order Creation:
  • Send a POST request to the orders controller to create an order from your cart.
  • This will clear the items from your cart.

Steps to reproduce in Postman

  1. Launch the app.
  2. Get your API address (use it in your future requests).
  3. Login to administrator account. image
  4. Paste access token to Authorization tab. image
  5. Get the list of products. image
  6. Add some pryaniks to the cart. image
  7. Check your cart. image
  8. Create an order. image
  9. Check your order. image
  10. Check products one more time and notice that the amount did change. image
  11. Check your cart and you'll see that there is nothing in there. image

That's all! If you want to check other possible requests, and see what it does, here is the api documentation.