Files
ShopSolution-backend/Webshop.Infrastructure/Repositories/CustomerRepository.cs
Tizian.Breuch 9e298a0458 aufrüumen
2025-07-25 15:46:31 +02:00

30 lines
833 B
C#

using Microsoft.EntityFrameworkCore;
using Webshop.Domain.Entities;
using Webshop.Domain.Interfaces;
using Webshop.Infrastructure.Data;
using System;
using System.Threading.Tasks;
namespace Webshop.Infrastructure.Repositories
{
public class CustomerRepository : ICustomerRepository
{
private readonly ApplicationDbContext _context;
public CustomerRepository(ApplicationDbContext context)
{
_context = context;
}
public async Task<Customer?> GetByUserIdAsync(string userId)
{
return await _context.Customers.FirstOrDefaultAsync(c => c.AspNetUserId == userId);
}
public async Task UpdateAsync(Customer customer)
{
_context.Customers.Update(customer);
await _context.SaveChangesAsync();
}
}
}