// src/Webshop.Infrastructure/Repositories/PaymentMethodRepository.cs using Microsoft.EntityFrameworkCore; using Webshop.Domain.Entities; using Webshop.Domain.Interfaces; using Webshop.Infrastructure.Data; using System; using System.Collections.Generic; using System.Threading.Tasks; namespace Webshop.Infrastructure.Repositories { public class PaymentMethodRepository : IPaymentMethodRepository { private readonly ApplicationDbContext _context; public PaymentMethodRepository(ApplicationDbContext context) { _context = context; } public async Task> GetAllAsync() => await _context.PaymentMethods.ToListAsync(); public async Task GetByIdAsync(Guid id) => await _context.PaymentMethods.FindAsync(id); public async Task AddAsync(PaymentMethod paymentMethod) { _context.PaymentMethods.Add(paymentMethod); await _context.SaveChangesAsync(); } public async Task UpdateAsync(PaymentMethod paymentMethod) { _context.PaymentMethods.Update(paymentMethod); await _context.SaveChangesAsync(); } public async Task DeleteAsync(Guid id) { var entity = await _context.PaymentMethods.FindAsync(id); if (entity != null) { _context.PaymentMethods.Remove(entity); await _context.SaveChangesAsync(); } } } }