Add pet action management and update requests
This commit is contained in:
1 parent
4c4036a266
commit
e1c5eed02d
12 files changed
+337
-36
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using pet_companion_api.Models;
|
||||
using pet_companion_api.Services;
|
||||
|
||||
namespace pet_companion_api.Controllers
|
||||
@@ -22,5 +23,26 @@ namespace pet_companion_api.Controllers
|
||||
{
|
||||
return Ok(petService.GetAllPets(userId));
|
||||
}
|
||||
|
||||
[HttpPost("")]
|
||||
public IActionResult CreatePet([FromBody] PetCreationRequest petRequest)
|
||||
{
|
||||
var createdPet = petService.CreatePet(userId, petRequest);
|
||||
return CreatedAtAction(nameof(GetAllPets), new { id = createdPet.Id }, createdPet);
|
||||
}
|
||||
|
||||
[HttpPut("{petId}/action")]
|
||||
public IActionResult UpdatePetAction(string petId, [FromBody] PetUpdateActionRequest actionRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var updatedPet = petService.UpdatePetAction(petId, userId.ToString(), actionRequest);
|
||||
return Ok(updatedPet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return NotFound(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user