Small application to store and retrieve Animal information for a fictional shelter
- C#
- HTMl/CSS
- ASP.NET Core MVC
- MySQL
- Entity Framework Core v 5.0
- Swagger
- Postman
This api database contains information on animals in a local shlter. Users are able to add, edit, view, and delete data entries through Either the Swagger UI or the MVC Client.
Install .NET Core
Cloning/Obtaining API File
-
Navigate to the AnimalShelterAPI
-
Clone or download the repo - follow these~instructions if this is your first time.
-
Open up your system Terminal or CMD prompt application in the directory you wish to host the project
-
Clone the repository using this command within the project directory
$ git clone https://github.com/CharWeber/AnimalShelterApi
AppSettings
- Create new file appsettings.json in AnimalShelterApi/Shelter
- Add the following code to the new appsettings.json, replacing the YOUR_PASSWORD_HERE with your mySQL password
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Port=3306;database=animal_shelter;uid=root;pwd=epicodus;",
"ConnStr": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=SarathlalDB;Integrated Security=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
}
}
Database Setup
-
In terminal, navigate into AnimalShelter/Shelter and run
$ dotnet restore
-
run this command to build database
$ dotnet ef database update
Launch API in Server
-
In AniamlShelterAAPI/Shelter, run this command to open the api in your browser
$ dotnet run
Explore the API endpoints in Postman or a browser using the Swagger UI.
To explore the API with Swagger, launch the project using dotnet run
with the Terminal or Powershell, and input the following URL into your browser: http://localhost:5000/swagger
..........................................................................................
Base URL: http://localhost:5000
GET /api/{component}
POST /api/{component}
GET /api/{component}/{id}
PUT /api/{component}/{id}
DELETE /api/{component}/{id}
https//localhost:5000/api/Animals/1
Access information about the listed Animals
GET /api/Animals
POST /api/Animals
GET /api/Animals/{id}
PUT /api/Review/{id}
DELETE /api/Review/{id}
Parameter | Type | Default | Required | Description |
---|---|---|---|---|
species | string | none | false | Return matches by species. |
http://localhost:5001/api/Animals/?species=cat
[
{
"animalId": 1,
"name": "Catface Meowmers",
"species": "cat",
"age": 1,
"gender": "male"
}
]
Base URL: http://localhost:5003
To Utilize the MVC Client you must have the Shelter project running on its Base URL
-
In terminal, navigate into SillyStringFactory.Solution/Factory/ and enter the command below to install necessary packages
$ dotnet restore
-
enter this command to build the program
$ dotnet build
-
enter the command below to view program in your browser
$ dotnet run
-
navigate to the Base URL in your browser
http://localhost:5003
- The edit route in the MVC doesn't seem to find the correct route. I'm not sure how to define the method route to put in the edit form. The API functions fine when calling the endpoint in swagger and postman so the issue is in the MVC
Author | GitHub | |
---|---|---|
Charles T Weber | CharWeber | charlestweber@gmail.com |