29 lines
676 B
C#
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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|