50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
|
using HanyadikHetVan.Data;
|
|||
|
using HanyadikHetVan.Data.Entities;
|
|||
|
using HanyadikHetVan.Interface;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace HanyadikHetVan.Repository
|
|||
|
{
|
|||
|
public class PauseRepository : IRepository<Pause>
|
|||
|
{
|
|||
|
private ApplicationDbContext _dbContext;
|
|||
|
|
|||
|
public PauseRepository(ApplicationDbContext applicationDbContext)
|
|||
|
{
|
|||
|
_dbContext = applicationDbContext ?? throw new ArgumentNullException(nameof(applicationDbContext));
|
|||
|
}
|
|||
|
|
|||
|
public async Task<Pause> Create(Pause _object)
|
|||
|
{
|
|||
|
var obj = await _dbContext.Pauses.AddAsync(_object);
|
|||
|
_dbContext.SaveChanges();
|
|||
|
return obj.Entity;
|
|||
|
}
|
|||
|
|
|||
|
public void Delete(Pause _object)
|
|||
|
{
|
|||
|
_dbContext.Remove(_object);
|
|||
|
_dbContext.SaveChanges();
|
|||
|
}
|
|||
|
|
|||
|
public IEnumerable<Pause> GetAll()
|
|||
|
{
|
|||
|
return _dbContext.Pauses.ToList();
|
|||
|
}
|
|||
|
|
|||
|
public Pause GetById(int Id)
|
|||
|
{
|
|||
|
return _dbContext.Pauses.Where(x => x.Id == Id).FirstOrDefault();
|
|||
|
}
|
|||
|
|
|||
|
public void Update(Pause _object)
|
|||
|
{
|
|||
|
_dbContext.Pauses.Update(_object);
|
|||
|
_dbContext.SaveChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|