initial commit

This commit is contained in:
2025-01-31 23:41:30 -03:00
commit 4c4036a266
22 changed files with 810 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore;
using pet_companion_api.Data;
using pet_companion_api.Models;
namespace pet_companion_api.Repositories
{
public class PetRepository
{
private readonly ApplicationDbContext _context;
public PetRepository(ApplicationDbContext context)
{
_context = context;
}
public IEnumerable<Pet> GetPetsByUserId(string userId)
{
return _context.Pets
.Where(p => p.UserId == userId)
.Include(p => p.Stats)
.Include(p => p.Resources)
.ToList();
}
public Pet CreatePet(Pet pet)
{
_context.Pets.Add(pet);
_context.SaveChanges();
return pet;
}
}
}