Question: You are about to create a Web API that provides support to allow logging incomes of clients. The API allow adding, removing, editing and querying

You are about to create a Web API that provides support to allow logging incomes of
clients. The API allow adding, removing, editing and querying user incomes. No client-
side implementation is required for this implementation.
Project Creation (10%)
Create an ASP.Net Core Web API Application project.
Name it (YourFirstName_YourLastName)
Delete WeatherForecastController and WeatherForecast class
Add a new api controller and call it IncomesController
Create Models folder then create Income class as following:
public class Income
{
public int Id { get; set; }
public string Description { get; set; }
public double Amount { get; set; }
public bool IsReceived { get; set; }
public int UserId { get; set; }
}
Make your first commit with a message that includes your name, the time in your
machine, and an appropriate message (e.g. "Aeiman: 12:30, project initialized)
Task 2: API endpoints: (80%)
Update the IncomesController so it provides the following endpoints.
Notes:
- the numbers given are just examples. The user should specify them as needed.
- You might need to use postman to create some incomes in the database so you
can test the different endpoints.
- You need to place the business logic in a static Repository class. Each endpoint
should call a relevant method in the static repository class to execute the
required tasks.
1. Endpoint GET /api/incomes/1
Return a number that represents the total (sum) income of the of the user
who has id =1(userid=1)
2. Endpoint GET /api/incomes/1/true
Return a list of all the incomes of the user who has id =1(userid=1) that
are received (IsReceived = true)
You need to add a custom route to allow receiving three
parameters in the action method.
[HttpGet("{userId}/{isReceived}}")]
3. Endpoint DELETE /api/incomes/1
Delete the incomes for the user 1(userid =1)
If the database doesnt have any income that matches the request
then the api should return a 404 error.
4. POST /api/incomes
Create a new income entry in the database
The new Income is supposed to be received in json format
The description and the amount are required. If the client doesnt
provide them, then the API should return an error.
Return the new created income to the client.
Make last commit with a message that includes your name, the time in your machine,
and an appropriate message (e.g. "Aeiman: 2:30, work is done)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!