not working inventory :c

This commit is contained in:
2025-02-04 17:47:18 -03:00
parent f234b5d84d
commit 7a2c3d2f67
22 changed files with 2713 additions and 49 deletions

View File

@@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore;
using PetCompanion.Data;
using PetCompanion.Models;
namespace PetCompanion.Repositories
{
public class PetSkillRepository
{
private readonly ApplicationDbContext _context;
public PetSkillRepository(ApplicationDbContext context)
{
_context = context;
}
public async Task<IEnumerable<PetSkill>> GetPetSkills(string petId)
{
return await _context.PetSkills
.Include(ps => ps.Skill)
.ThenInclude(s => s.Effects)
.Where(ps => ps.PetId == petId)
.ToListAsync();
}
public async Task<PetSkill> SavePetSkill(PetSkill petSkill)
{
if (petSkill.Id == 0)
{
_context.PetSkills.Add(petSkill);
}
else
{
_context.PetSkills.Update(petSkill);
}
await _context.SaveChangesAsync();
return petSkill;
}
}
}