Coder Social home page Coder Social logo

animalshelterapi.solution's Introduction

Animal Shelter API v 1.0

A C# web API for Cats and Dogs

By Ryan Walker

Description

An API that allows users to View, Add, Edit, and Delete cats and dogs from an imaginary Animal Shelter's archive. A user may interact with the in-use version of the API using Postman or the built-in Swagger UI. Additionally, users may download the corresponding Animal Shelter Client web application here

Setup and Use

Prerequisites

Installation

  1. Clone the repository: $ git clone https://github.com/RyanDanielWalker/AnimalShelterAPI.Solution
  2. Navigate to the AnimalShelterAPI.Solution/ directory on your computer
  3. Open with your preferred text editor to view the code base

Connecting project to database via appsettings.json

  1. In the production folder AnimalShelterAPI.Solution/AnimalShelterAPI create a file called appsettings.json
  2. Add the following code:
{
  "Logging": {
    "LogLevel": {
      "Default": "Warning",
      "System": "Information",
      "Microsoft": "Information"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "DefaultConnection": "Server={YOUR_SERVER};Port={YOUR_PORT};database={YOUR_SCHEMA_NAME};uid=root;pwd={YOUR_PASSWORD};"
  }
}
  • Fill in the desired name of your server, port, schema and MySQL Workbench password, omitting the curly braces

To run the API:

  1. Navigate to AnimalShelterAPI.Solution/AnimalShelterAPI in your command line
  2. Run the command dotnet restore to restore the dependencies that are listed in the .csproj
  3. Run the command dotnet build to build the project and its dependencies into a set of binaries
  4. Run the command dotnet ef database update to create database and populate tables
  5. If you wish to update the database with any changes to the code, run the command dotnet ef migrations add {MigrationName} and again dotnet ef database update
  6. Finally, run the command dotnet run to run the project!
  7. Note: dotnet run also restores and builds the project, so you can use this single command to start the app

API Documentation

Client Application

  1. Download the corresponding Animal Shelter API client web application here

Swagger

  1. After launching the project with dotnet run gain access to the API with Swagger by visiting localhost:5000/swagger

Postman

  1. Explore API endpoints using Postman

API Endpoints

Request URL https://localhost:5000

Cats

HTTP Request Structure for Cats

GET /api/cats
POST /api/cats
GET /api/cats/{id}
PUT /api/cats/{id}
DELETE /api/cats/{id}

Sample Request URL

https://localhost:5001/api/Cats?name=doug

Sample JSON Response for Cats

  { 
    "catId": 1,
    "name": "Doug",
    "age": 4,
    "gender": "Male",
    "description": "Lovely"
  }

Dogs

HTTP Request Structure for Dogs

GET /api/dogs
POST /api/dogs
GET /api/dogs/{id}
PUT /api/dogs/{id}
DELETE /api/dogs/{id}

Sample Request URL

https://localhost:5001/api/Dogs?name=emma

Sample JSON Response for Dogs

  {
    "dogId": 5,
    "name": "Emma",
    "age": 18,
    "gender": "Female",
    "description": "Lovely"
  }

Known Bugs

There were no bugs found

Technologies Used

  • ASP .NET Core MVC
  • C#
  • VS Code
  • MySQL Workbench
  • MySQL
  • Entity Framework Core
  • LINQ
  • Swagger
  • Swashbuckle.AspNetCore
  • Postman
  • AspNetCore Mvc Versioning

License

MIT

Copyright (c) 2021 Ryan Walker

Contact Information

[email protected]

animalshelterapi.solution's People

Contributors

ryandanielwalker avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.