add crud
This commit is contained in:
parent
030a254b6b
commit
8930d4e20d
21
HanyadikHetVan/Interface/IRepository.cs
Normal file
21
HanyadikHetVan/Interface/IRepository.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HanyadikHetVan.Interface
|
||||
{
|
||||
public interface IRepository<T>
|
||||
{
|
||||
public Task<T> Create(T _object);
|
||||
|
||||
public void Update(T _object);
|
||||
|
||||
public IEnumerable<T> GetAll();
|
||||
|
||||
public T GetById(int Id);
|
||||
|
||||
public void Delete(T _object);
|
||||
|
||||
}
|
||||
}
|
49
HanyadikHetVan/Repository/PauseRepository.cs
Normal file
49
HanyadikHetVan/Repository/PauseRepository.cs
Normal file
@ -0,0 +1,49 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
49
HanyadikHetVan/Repository/WeeklyTimeSpanRepository.cs
Normal file
49
HanyadikHetVan/Repository/WeeklyTimeSpanRepository.cs
Normal file
@ -0,0 +1,49 @@
|
||||
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 WeeklyTimeSpanRepository : IRepository<WeeklyTimeSpan>
|
||||
{
|
||||
private ApplicationDbContext _dbContext;
|
||||
|
||||
public WeeklyTimeSpanRepository(ApplicationDbContext applicationDbContext)
|
||||
{
|
||||
_dbContext = applicationDbContext ?? throw new ArgumentNullException(nameof(applicationDbContext));
|
||||
}
|
||||
|
||||
public async Task<WeeklyTimeSpan> Create(WeeklyTimeSpan _object)
|
||||
{
|
||||
var obj = await _dbContext.WeeklyTimeSpans.AddAsync(_object);
|
||||
_dbContext.SaveChanges();
|
||||
return obj.Entity;
|
||||
}
|
||||
|
||||
public void Delete(WeeklyTimeSpan _object)
|
||||
{
|
||||
_dbContext.Remove(_object);
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
public IEnumerable<WeeklyTimeSpan> GetAll()
|
||||
{
|
||||
return _dbContext.WeeklyTimeSpans.ToList();
|
||||
}
|
||||
|
||||
public WeeklyTimeSpan GetById(int Id)
|
||||
{
|
||||
return _dbContext.WeeklyTimeSpans.Where(x => x.Id == Id).FirstOrDefault();
|
||||
}
|
||||
|
||||
public void Update(WeeklyTimeSpan _object)
|
||||
{
|
||||
_dbContext.WeeklyTimeSpans.Update(_object);
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user