initial commit
This commit is contained in:
31
Services/PetService.cs
Normal file
31
Services/PetService.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using pet_companion_api.Models;
|
||||
using pet_companion_api.Repositories;
|
||||
|
||||
namespace pet_companion_api.Services
|
||||
{
|
||||
public class PetService
|
||||
{
|
||||
private readonly PetRepository petRepository;
|
||||
|
||||
public PetService(PetRepository petRepository)
|
||||
{
|
||||
this.petRepository = petRepository;
|
||||
}
|
||||
|
||||
public IEnumerable<Pet> GetAllPets(Guid userId)
|
||||
{
|
||||
return petRepository.GetPetsByUserId(userId.ToString());
|
||||
}
|
||||
|
||||
public Pet CreatePet(Guid userId, Pet pet)
|
||||
{
|
||||
pet.Id = Guid.NewGuid().ToString();
|
||||
pet.UserId = userId.ToString();
|
||||
pet.Level = 1;
|
||||
pet.Stats = new PetStats(pet.Class);
|
||||
pet.Resources = new Resources();
|
||||
|
||||
return petRepository.CreatePet(pet);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user