shop info
This commit is contained in:
@@ -30,6 +30,7 @@ namespace Webshop.Infrastructure.Data
|
||||
public DbSet<ProductDiscount> ProductDiscounts { get; set; } = default!;
|
||||
public DbSet<CategorieDiscount> categorieDiscounts { get; set; } = default!;
|
||||
public DbSet<ProductImage> ProductImages { get; set; } = default!;
|
||||
public DbSet<ShopInfo> ShopInfos { get; set; } = default!;
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
|
||||
37
Webshop.Infrastructure/Repositories/ShopInfoRepository.cs
Normal file
37
Webshop.Infrastructure/Repositories/ShopInfoRepository.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user