Agent-Banks / PetDatabaseAPI

You will be creating an API that allows a user to create and care for a virtual pet, reminiscent of a Tamagotchi. The basic functionality will walk you through the four basic parts of a web API, create, read, update and delete.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SDG Assignment #14 : 04 - 04 - The Rise of the Tamagotchi

To start your journey you will be creating an API that allows a user to create and care for a virtual pet, reminiscent of a Tamagotchi. The basic functionality will walk you through the four basic parts of a web API, create, read, update and delete.

Objectives

  • Create an API that can implement CRUD features against a Database.
  • Practice creating ASP.NET Web API endpoints.
  • Practice EF Core.

Explorer Mode

  • Create and new sdg-api that has the following features

  • Create a database with one table named Pets.

    • Should use a POCO called Pet with the following columns:
      • Id (int)
      • Name (string)
      • Birthday (DateTime)
      • HungerLevel (int)
      • HappinessLevel (int)

Your API should have the following endpoints

  • GET /pets, should return all pets in your database.
  • GET /pets/{id}, should return the pet with the corresponding id.
  • POST /pets, should create a new pet. The body of the request should contain a JSON object with a key of "name" and a value of the pet's name. The pets Birthday should default to the current datetime, HungerLevel defaults to 0 and HappinessLevel defaults to 0.
  • POST /pets/{id}/playtimes, should find the pet by id and add 5 to its happiness level and 3 to its hungry level.
  • POST /pets/{id}/feedings, should find the pet by id and subtract 5 from its hungry level and 3 from its happiness level.
  • POST /pets/{id}/scoldings, should find the pet by id and subtract 5 from its happiness level.
  • DELETE /pets/{id}, should delete a pet from the database by Id

Adventure Mode

Add the following features to your API

  • Add columns LastInteractedWithDate (DateTime). Every time a pet us updated in the database, set the LastInteractedWithDate to the current time. Add a property named IsDead to your Pets that has logic such that if the LastInteractedWithDate is over 3 days old, the property returns true otherwise false.
  • Add a query parameter go GET /pets that only returns Pets that are alive.

Epic mode

Create a console app that interacts with your API that:

  • Allows the user to see all pets
  • Select a pet to take care of and then play with, scold, or feed the selected pet.
  • Create a new pet.
  • Delete a pet.

Resources

About

You will be creating an API that allows a user to create and care for a virtual pet, reminiscent of a Tamagotchi. The basic functionality will walk you through the four basic parts of a web API, create, read, update and delete.


Languages

Language:C# 61.8%Language:HTML 36.6%Language:Rich Text Format 1.7%