Animal Shelter API

A basic API for an animal shelter that can be used to list available cats and dogs at the shelter available for adoption.

By Shane Graff

Table of Contents

  1. Technologies Used
  2. Setup/Installation Requirements
  3. Api Info/Endpoinst
  4. Known Bugs
  5. License
  6. Contact Information

Technologies Used

Setup/Installation Requirements

  1. If you don't already have C# and .NET installed on your computer, you can get the Software Develment Kit or SDK for Mac here: Dot.Net for Mac and for Windows here: Dot.Net for Windows. Follow the instructions detailed in both links above for set up.
  2. If not already installed, download: MySql Community
  3. If not already installed, download: MySql Workbench
  4. Follow the instruction here for configuring MySql.
  5. Open the terminal on your local machine and navigate to where you want to clone the project
  6. Run the following command: git clone https://github.com/ShanGGraff/AnimalShelter.Solution.
  7. Navigate to the AnimalShelter/ directory and create a file named: appsettings.json. In this file, add the folling configuration to be able to create the table used by the application:
{
  "Logging": {
    "LogLevel": {
      "Default": "Warning",
      "System": "Information",
      "Microsoft": "Information"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Port=3306;database=animal_shelter;uid=root;pwd=[YOUR-PASSWORD-HERE];"
  }
}
  1. If you don't already of migragtions installed for creating the table, add the package with the following: dotnet add package Microsoft.EntityFrameworkCore.Design -v 5.0.0 on the command line in the AnimalShelter main directory.
  2. In the SweetAndSavory main directory run dotnet build on the command line to check for errors
  3. Next run dotnet ef migrations add Initial. Note when making changes to the schema (i.e. making changes in the models that affect the database such as adding a new attribute, you would change "Initial" to something more descriptive of what change you are making to the table.
  4. Nex run dotnet ef database update to update the table/s. I've included values in the AnimalShelterContext.cs to seed the database with some animal entries for testing.
  5. Run dotnet build again to make sure there are no errors.
  6. If everything builds correctly, run dotnet run on the command line to start the AnimalShelter API.

Api Endpoints/Documentation

The API enpoints are the following:

GET /api/Animals (returns a list of the animals at the shelter)
POST /api/Animals (allows user to add new animal to the database)
GET /api/Animals/{id} (list an animal by a specific id)
PUT /api/Animals/{id} (change information about a specific animal)
DELETE /api/Animals/{id} (delete a specific animal by id)

Here is an example of available user queries:

  • A basic list of all the animals at the shelter:
https://localhost:5001/api/Animals/
  • Listing an animal by id:
http://localhost:5000/api/Animals/2
  • Searching by multiple attributes
http://localhost:5000/api/animals/?species=cat&gender=female&age=1

Known Bugs

  • No known

License

Copyright (c) 2021 Creators

Contact Information