30 lines
833 B
C#
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();
|
|
}
|
|
}
|
|
} |