using System;
using System.Collections.Generic;
using Umbraco.Core.Models;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.UnitOfWork;
using umbraco.interfaces;
namespace Umbraco.Core.Services
{
internal class NotificationService : INotificationService
{
private readonly IDatabaseUnitOfWorkProvider _uowProvider;
public NotificationService(IDatabaseUnitOfWorkProvider provider)
{
_uowProvider = provider;
}
///
/// Sends the notifications for the specified user regarding the specified node and action.
///
///
///
///
public void SendNotifications(IEntity entity, IUser user, IAction action)
{
throw new NotImplementedException();
}
///
/// Gets the notifications for the user
///
///
///
public IEnumerable GetUserNotifications(IUser user)
{
var uow = _uowProvider.GetUnitOfWork();
var repository = new NotificationsRepository(uow);
return repository.GetUserNotifications(user);
}
///
/// Deletes notifications by entity
///
///
public IEnumerable GetEntityNotifications(IEntity entity)
{
var uow = _uowProvider.GetUnitOfWork();
var repository = new NotificationsRepository(uow);
return repository.GetEntityNotifications(entity);
}
///
/// Deletes notifications by entity
///
///
public void DeleteNotifications(IEntity entity)
{
var uow = _uowProvider.GetUnitOfWork();
var repository = new NotificationsRepository(uow);
repository.DeleteNotifications(entity);
}
///
/// Deletes notifications by user
///
///
public void DeleteNotifications(IUser user)
{
var uow = _uowProvider.GetUnitOfWork();
var repository = new NotificationsRepository(uow);
repository.DeleteNotifications(user);
}
///
/// Delete notifications by user and entity
///
///
///
public void DeleteNotifications(IUser user, IEntity entity)
{
var uow = _uowProvider.GetUnitOfWork();
var repository = new NotificationsRepository(uow);
repository.DeleteNotifications(user, entity);
}
///
/// Creates a new notification
///
///
///
/// The action letter - note: this is a string for future compatibility
///
public Notification CreateNotification(IUser user, IEntity entity, string action)
{
var uow = _uowProvider.GetUnitOfWork();
var repository = new NotificationsRepository(uow);
return repository.CreateNotification(user, entity, action);
}
}
}