37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
// src/Webshop.Infrastructure/Repositories/ShopInfoRepository.cs
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System.Threading.Tasks;
|
|
using Webshop.Domain.Entities;
|
|
using Webshop.Domain.Interfaces;
|
|
using Webshop.Infrastructure.Data;
|
|
|
|
namespace Webshop.Infrastructure.Repositories
|
|
{
|
|
public class ShopInfoRepository : IShopInfoRepository
|
|
{
|
|
private readonly ApplicationDbContext _context;
|
|
|
|
public ShopInfoRepository(ApplicationDbContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<ShopInfo?> GetAsync()
|
|
{
|
|
// Es sollte immer nur eine Zeile geben, also nehmen wir die erste
|
|
return await _context.ShopInfos.FirstOrDefaultAsync();
|
|
}
|
|
|
|
public async Task UpdateAsync(ShopInfo shopInfo)
|
|
{
|
|
_context.ShopInfos.Update(shopInfo);
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
|
|
public async Task AddAsync(ShopInfo shopInfo)
|
|
{
|
|
await _context.ShopInfos.AddAsync(shopInfo);
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
}
|
|
} |