32 lines
814 B
C#
32 lines
814 B
C#
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);
|
|
}
|
|
}
|
|
}
|