record-my-ruck/RecordMyRuck/Models/RuckRepository.cs

29 lines
676 B
C#
Raw Permalink Normal View History

2024-05-17 04:30:18 +00:00
namespace RecordMyRuck.Models
{
public class RuckRepository : IRuckRepository
{
RecordMyRuckDbContext _dbContext;
public RuckRepository(RecordMyRuckDbContext dbContext)
{
_dbContext = dbContext;
}
public void CreateRuck(Ruck ruck)
{
_dbContext.Rucks.Add(ruck);
_dbContext.SaveChanges();
}
public Ruck? Get(DateTime dateTime)
{
return _dbContext.Rucks.FirstOrDefault(r => r.DateTime == dateTime);
}
public IEnumerable<Ruck> GetAll()
{
return _dbContext.Rucks;
}
}
}