41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using _0_Framework.Application;
|
|
using _0_Framework.InfraStructure;
|
|
using AccountManagement.Application.Contracts.TicketAccessAccount;
|
|
using AccountManagement.Domain.TicketAccessAccountAgg;
|
|
|
|
namespace AccountMangement.Infrastructure.EFCore.Repository;
|
|
|
|
public class TicketAccessAccountRepository:RepositoryBase<long,TicketAccessAccount>, ITicketAccessAccountRepository
|
|
{
|
|
private readonly AccountContext _accountContext;
|
|
|
|
public TicketAccessAccountRepository(AccountContext accountContext):base(accountContext)
|
|
{
|
|
_accountContext = accountContext;
|
|
}
|
|
|
|
public bool HasTicketAccess(long accountId)
|
|
{
|
|
return _accountContext.TicketAccessAccounts.Any(x => x.AccountId == accountId);
|
|
}
|
|
|
|
public List<TicketAccessAccountViewModel> GetAllAccessedAccounts()
|
|
{
|
|
return _accountContext.TicketAccessAccounts.Select(x => new TicketAccessAccountViewModel()
|
|
{
|
|
CreateDateFa = x.CreationDate.ToFarsi(),
|
|
Name = _accountContext.Accounts.FirstOrDefault(a => a.id == x.AccountId).Fullname,
|
|
AccountId = x.AccountId,
|
|
Id = x.id
|
|
}).ToList();
|
|
}
|
|
|
|
public void Remove(long id)
|
|
{
|
|
var entity = Get(id);
|
|
_accountContext.Remove(entity);
|
|
|
|
}
|
|
} |