using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using GreenTree.Nachtragsmanagement.Core.Data; using GreenTree.Nachtragsmanagement.Core.Domain.Misc; namespace GreenTree.Nachtragsmanagement.Services.Misc { public class MiscService : IMiscService { #region Fields private readonly IRepository _mailNotificationRepository; private readonly IRepository _helpPageRepository; #endregion #region Ctor /// /// Initializes a new instance of the MiscService class /// public MiscService( IRepository mailNotificationRepository, IRepository helpPageRepository) { _mailNotificationRepository = mailNotificationRepository; _helpPageRepository = helpPageRepository; } #endregion #region MailNotification /// /// Gets all mailNotifications /// public IList GetAllMailNotifications() { return _mailNotificationRepository.Table.ToList(); } /// /// Gets a mailNotification by specified Id /// /// MailNotification identifier. public MailNotification GetMailNotificationById(int id) { return _mailNotificationRepository.GetById(id); } /// /// Gets all mailNotifications to the specified ids /// public IList GetMailNotificationsByIds(int[] ids) { return _mailNotificationRepository.Table .Where(u => ids.Contains(u.Id)) .ToList(); } /// /// Insert a mailNotification /// /// MailNotification. public void InsertMailNotification(MailNotification mailNotification) { _mailNotificationRepository.Insert(mailNotification); } /// /// Update a mailNotification /// /// MailNotification. public void UpdateMailNotification(MailNotification mailNotification) { _mailNotificationRepository.Update(mailNotification); } /// /// Delete a mailNotification /// /// MailNotification. public void DeleteMailNotification(MailNotification mailNotification) { _mailNotificationRepository.Delete(mailNotification); } #endregion #region HelpPage /// /// Gets all helpPages /// public IList GetAllHelpPages() { return _helpPageRepository.Table.ToList(); } /// /// Gets all helpPages without actual content /// public IList GetAllHelpPagesWithoutContent() { return _helpPageRepository.Table .ToList() .Select(u => new HelpPage { Id = u.Id, Children = u.Children, DisplayIndex = u.DisplayIndex, Parent = u.Parent, ParentId = u.ParentId, Title = u.Title }) .ToList(); } /// /// Gets a helpPage by specified Id /// /// HelpPage identifier. public HelpPage GetHelpPageById(int id) { return _helpPageRepository.GetById(id); } /// /// Gets all helpPages to the specified ids /// public IList GetHelpPagesByIds(int[] ids) { return _helpPageRepository.Table .Where(u => ids.Contains(u.Id)) .ToList(); } /// /// Insert a helpPage /// /// HelpPage. public void InsertHelpPage(HelpPage helpPage) { _helpPageRepository.Insert(helpPage); } /// /// Update a helpPage /// /// HelpPage. public void UpdateHelpPage(HelpPage helpPage) { _helpPageRepository.Update(helpPage); } /// /// Delete a helpPage /// /// HelpPage. public void DeleteHelpPage(HelpPage helpPage) { _helpPageRepository.Delete(helpPage); } #endregion } }