| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using Diligent.WebAPI.Business.Interfaces;
- using Diligent.WebAPI.Data.Entities;
- using Microsoft.AspNetCore.Identity;
- using System.Diagnostics.CodeAnalysis;
-
- namespace Diligent.WebAPI.Business.Services
- {
- [ExcludeFromCodeCoverage]
- public class CustomerRepository : ICustomerRepository
- {
- private readonly UserManager<Customer> _customerManager;
-
- public CustomerRepository(UserManager<Customer> customerManager)
- {
- _customerManager = customerManager;
- }
-
- public async Task<Customer> GetCustomer(string username)
- {
- var customer = await _customerManager.FindByNameAsync(username);
- return customer;
- }
-
- public async Task<Customer> GetCustomerById(string id)
- {
- var customer = await _customerManager.FindByIdAsync(id);
- return customer;
- }
-
- public async Task AddNotification(Customer receiver)
- {
- await _customerManager.UpdateAsync(receiver);
- }
-
- public async Task<List<Notification>> ReadNotifications(string userId)
- {
- var user = await _customerManager.FindByIdAsync(userId);
-
- return user.Notifications;
- }
-
- public async Task DeleteNotification(Customer user, Notification notification)
- {
- user.Notifications.Remove(notification);
- await _customerManager.UpdateAsync(user);
- }
- }
- }
|