Files
Backend-Api/AccountMangement.Infrastructure.EFCore/Repository/AccountLeftworkRepository.cs

56 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using AccountManagement.Application.Contracts.Account;
using AccountManagement.Domain.AccountLeftWorkAgg;
using Company.Domain.LeftWorkAgg;
using Company.Domain.WorkingHoursItemsAgg;
using Company.Domain.WorkshopAccountAgg;
using Microsoft.EntityFrameworkCore;
namespace AccountMangement.Infrastructure.EFCore.Repository;
public class AccountLeftworkRepository : RepositoryBase<long, AccountLeftWork>, IAccountLeftworkRepository
{
private readonly AccountContext _accountContext;
private readonly IWorkshopAccountRepository _workshopAccountRepository;
public AccountLeftworkRepository(AccountContext accountContext, IWorkshopAccountRepository workshopAccountRepository) : base(accountContext)
{
_accountContext = accountContext;
_workshopAccountRepository = workshopAccountRepository;
}
public (string StartWorkFa, string LeftWorkFa) GetByAccountId(long accountId)
{
var initial = new DateTime(2150, 1, 1);
string start = "";
string end = "";
var res = _accountContext.AccountLeftWorks.FirstOrDefault(x => x.AccountId == accountId);
if (res != null)
{
start = res.StartWorkGr != initial ? res.StartWorkGr.ToFarsi() : "";
end = res.LeftWorkGr != initial ? res.LeftWorkGr.ToFarsi() : "";
}
return (start, end);
}
public List<WorkshopAccountlistViewModel> WorkshopList(long accountId)
{
var res = _workshopAccountRepository.GetList(accountId);
return res.Select(x => new WorkshopAccountlistViewModel
{
WorkshopId = x.WorkshopId,
WorkshopName = x.WorkshopName,
AccountId = x.AccountId,
ContractAndCheckout = x.ContractAndCheckout,
Insurance = x.Insurance,
Tax = x.Tax,
IsActiveSting = x.IsActiveSting,
}).ToList();
}
}