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
Create an ASP.Net Core Web API Application project.
Name it YourFirstNameYourLastName
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 eg "Aeiman: : project initialized
Task : API endpoints:
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.
Endpoint GET apiincomes
Return a number that represents the total sum income of the of the user
who has id userid
Endpoint GET apiincomestrue
Return a list of all the incomes of the user who has id userid that
are received IsReceived true
You need to add a custom route to allow receiving three
parameters in the action method.
HttpGetuserIdisReceived
Endpoint DELETE apiincomes
Delete the incomes for the user userid
If the database doesnt have any income that matches the request
then the api should return a error.
POST apiincomes
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 eg "Aeiman: : work is done
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
