45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using LCU.Shared.Collections.RepoApiLib.Models;
|
|
using LCU.Shared.Collections.RepoApiLib.Persistence;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace LCU.Shared.Collections.RepoApiLib.Repositories
|
|
{
|
|
public class RepoCompanyRepository : BaseRepository, IRepoCompanyRepository
|
|
{
|
|
public RepoCompanyRepository(AppDbContext context) : base(context)
|
|
{
|
|
}
|
|
|
|
public async Task<IEnumerable<RepoCompany>> ListAsync()
|
|
{
|
|
return await _context.RepoCompanies.ToListAsync();
|
|
}
|
|
|
|
public async Task<RepoCompany> AddAsync(RepoCompany repoCompany)
|
|
{
|
|
var result = await _context.RepoCompanies.AddAsync(repoCompany);
|
|
return result.Entity;
|
|
}
|
|
|
|
public async Task<RepoCompany> FindByIdAsync(int id)
|
|
{
|
|
return await Queryable.Where<RepoCompany>(_context.RepoCompanies, x => x.ID == id).FirstOrDefaultAsync();
|
|
}
|
|
|
|
|
|
public void Update(RepoCompany repoCompany)
|
|
{
|
|
_context.RepoCompanies.Update(repoCompany);
|
|
}
|
|
|
|
public void Remove(RepoCompany repoCompany)
|
|
{
|
|
_context.RepoCompanies.Remove(repoCompany);
|
|
}
|
|
}
|
|
}
|