37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
// BackgroundBuilder\Services\ContactService.cs
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using BackgroundBuilder.Models;
|
|
using BackgroundBuilder.Repositories;
|
|
|
|
namespace BackgroundBuilder.Services
|
|
{
|
|
public class ContactService(IContatoRepository repo) : IContactService
|
|
{
|
|
private readonly IContatoRepository _repo = repo;
|
|
|
|
public Task<IEnumerable<Contato>> GetAllAsync()
|
|
=> _repo.GetAllAsync();
|
|
|
|
public Task InsertUpdateAsync(Contato contato)
|
|
=> _repo.InsertUpdateAsync(contato);
|
|
|
|
public Task AddAsync(Contato contato)
|
|
=> _repo.InsertUpdateAsync(contato);
|
|
|
|
public Task DeleteAsync(string ramal)
|
|
=> _repo.DeleteAsync(ramal);
|
|
|
|
public IEnumerable<Contato> GetComando(IEnumerable<Contato> all)
|
|
=> all.Where(c => c.IsComando);
|
|
|
|
public IEnumerable<Contato> GetSemComando(IEnumerable<Contato> all)
|
|
=> all.Where(c => !c.IsComando).OrderBy(x => x.Nome);
|
|
|
|
public IEnumerable<Contato> GetAniversarios(IEnumerable<Contato> all)
|
|
=> all.Where(c => c.Aniversario.HasValue).OrderBy(x => (x.Aniversario ?? DateTime.MinValue).Day).OrderBy(x => (x.Aniversario ?? DateTime.MinValue).Month);
|
|
}
|
|
}
|