record-my-ruck/RecordMyRuck/Models/RuckRepository.cs
2024-05-16 22:30:18 -06:00

29 lines
676 B
C#

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;
}
}
}