552 lines
24 KiB
C#
552 lines
24 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using _0_Framework_b.InfraStructure;
|
|
using _0_Framework_b.Application;
|
|
using Company.Domain.File1;
|
|
using CompanyManagment.App.Contracts.Employee;
|
|
using CompanyManagment.App.Contracts.Employer;
|
|
using CompanyManagment.App.Contracts.File1;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using PersianTools.Core;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CompanyManagment.EFCore.Repository;
|
|
|
|
public class FileRepository : RepositoryBase<long, Company.Domain.File1.File1>, IFileRepository
|
|
{
|
|
private readonly CompanyContext _context;
|
|
public FileRepository(CompanyContext context) : base(context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public EditFile GetDetails(long id)
|
|
{
|
|
return _context.Files.Select(x => new EditFile
|
|
{
|
|
Id = x.id,
|
|
ArchiveNo = x.ArchiveNo,
|
|
ClientVisitDate = x.ClientVisitDate.ToFarsi(),
|
|
ProceederReference = x.ProceederReference,
|
|
Reqester = x.Reqester,
|
|
Summoned = x.Summoned,
|
|
Client = x.Client,
|
|
FileClass = x.FileClass,
|
|
HasMandate = x.HasMandate,
|
|
Description = x.Description,
|
|
Status = x.Status
|
|
}).FirstOrDefault(x => x.Id == id);
|
|
}
|
|
|
|
public List<FileViewModel> Search(FileSearchModel searchModel)
|
|
{
|
|
var query = _context.Files.Select(x => new FileViewModel
|
|
{
|
|
Id = x.id,
|
|
ArchiveNo = x.ArchiveNo,
|
|
ClientVisitDate = x.ClientVisitDate.ToFarsi(),
|
|
ProceederReference = x.ProceederReference,
|
|
Reqester = x.Reqester,
|
|
Summoned = x.Summoned,
|
|
Client = x.Client,
|
|
FileClass = x.FileClass,
|
|
HasMandate = x.HasMandate,
|
|
Description = x.Description,
|
|
Status = x.Status
|
|
});
|
|
|
|
//var query = _context.Files
|
|
// .Include(f => f.BoardsList)
|
|
// .Include(f => f.PetitionsList)
|
|
// .Include(f => f.EvidencesList)
|
|
// .Include(f => f.MasterPetitionsList)
|
|
// .Select(x => new
|
|
// {
|
|
// Id = x.id,
|
|
// ArchiveNo = x.ArchiveNo,
|
|
// ClientVisitDate = x.ClientVisitDate.ToFarsi(),
|
|
// ProceederReference = x.ProceederReference,
|
|
// Reqester = x.Reqester,
|
|
// Summoned = x.Summoned,
|
|
// Client = x.Client,
|
|
// FileClass = x.FileClass,
|
|
// HasMandate = x.HasMandate,
|
|
// Description = x.Description,
|
|
// Status = x.Status,
|
|
// DiagnosisBoard = x.BoardsList.Where(b => b.BoardType.Id == 1).FirstOrDefault(),
|
|
// DisputeResolutionBoard = x.BoardsList.Where(b => b.BoardType.Id == 2).FirstOrDefault(),
|
|
// DiagnosisPetition = x.PetitionsList.Where(p => p.BoardType.Id == 1).FirstOrDefault(),
|
|
// DisputeResolutionPetition = x.PetitionsList.Where(p => p.BoardType.Id == 2).FirstOrDefault(),
|
|
// DiagnosisEvidence = x.EvidencesList.Where(e => e.BoardType_Id == 1).FirstOrDefault(),
|
|
// DisputeResolutionEvidence = x.EvidencesList.Where(e => e.BoardType_Id == 2).FirstOrDefault(),
|
|
// DiagnosisMasterPetition = x.MasterPetitionsList.Where(e => e.BoardType_Id == 1).FirstOrDefault(),
|
|
// DisputeResolutionMasterPetition = x.MasterPetitionsList.Where(e => e.BoardType_Id == 1).FirstOrDefault(),
|
|
// FirstDiagnosisPS = x.BoardsList.Where(b => b.BoardType.Id == 1).FirstOrDefault().ProceedingSessionsList.FirstOrDefault(),
|
|
// LastDiagnosisPS = x.BoardsList.Where(b => b.BoardType.Id == 1).FirstOrDefault().ProceedingSessionsList.OrderBy(p => p.id).Skip(1).LastOrDefault(),
|
|
// FirstDisputeResolutionPS = x.BoardsList.Where(b => b.BoardType.Id == 2).FirstOrDefault().ProceedingSessionsList.FirstOrDefault(),
|
|
// LastDisputeResolutionPS = x.BoardsList.Where(b => b.BoardType.Id == 2).FirstOrDefault().ProceedingSessionsList.OrderBy(p => p.id).Skip(1).LastOrDefault(),
|
|
// });
|
|
|
|
|
|
if (searchModel.Id != 0)
|
|
{
|
|
query = query.Where(x => x.Id == searchModel.Id);
|
|
}
|
|
|
|
//TODO if
|
|
if (searchModel.ArchiveNo != null && int.Parse(searchModel.ArchiveNo) != -1)
|
|
{
|
|
query = query.Where(x => x.ArchiveNo == int.Parse(searchModel.ArchiveNo));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(searchModel.FileClass) && searchModel.FileClass != "-1")
|
|
{
|
|
query = query.Where(x => x.FileClass.Contains(searchModel.FileClass));
|
|
}
|
|
|
|
if (searchModel.UserId != 0)
|
|
{
|
|
if (searchModel.Client == 0)
|
|
query = query.Where(x => x.Reqester == searchModel.UserId || x.Summoned == searchModel.UserId);
|
|
|
|
else if (searchModel.Client == 1)
|
|
query = query.Where(x => x.Reqester == searchModel.UserId);
|
|
|
|
else
|
|
query = query.Where(x => x.Summoned == searchModel.UserId);
|
|
}
|
|
|
|
if (searchModel.Status != 0)
|
|
{
|
|
query = query.Where(x => x.Status == searchModel.Status);
|
|
}
|
|
|
|
return query.OrderByDescending(x => x.ArchiveNo).ToList();
|
|
|
|
//var res = query.OrderByDescending(x => x.ArchiveNo).ToList();
|
|
|
|
//var result = res.Select(x => new FileViewModel
|
|
//{
|
|
// Id = x.Id,
|
|
// ArchiveNo = x.ArchiveNo,
|
|
// ClientVisitDate = x.ClientVisitDate,
|
|
// ProceederReference = x.ProceederReference,
|
|
// Reqester = x.Reqester,
|
|
// Summoned = x.Summoned,
|
|
// Client = x.Client,
|
|
// FileClass = x.FileClass,
|
|
// HasMandate = x.HasMandate,
|
|
// Description = x.Description,
|
|
// Status = x.Status,
|
|
|
|
// DiagnosisBoard = x.DiagnosisBoard == null
|
|
// ? new EditBoard()
|
|
// : new EditBoard
|
|
// {
|
|
// Id = x.DiagnosisBoard.id,
|
|
// BoardChairman = x.DiagnosisBoard.BoardChairman,
|
|
// BoardType_Id = x.DiagnosisBoard.BoardType_Id,
|
|
// Branch = x.DiagnosisBoard.Branch,
|
|
// DisputeResolutionPetitionDate = x.DiagnosisBoard.DisputeResolutionPetitionDate.ToFarsi(),
|
|
// ExpertReport = x.DiagnosisBoard.ExpertReport,
|
|
// File_Id = x.DiagnosisBoard.File_Id
|
|
// },
|
|
// DisputeResolutionBoard = x.DisputeResolutionBoard == null
|
|
// ? new EditBoard()
|
|
// : new EditBoard
|
|
// {
|
|
// Id = x.DisputeResolutionBoard.id,
|
|
// BoardChairman = x.DisputeResolutionBoard.BoardChairman,
|
|
// BoardType_Id = x.DisputeResolutionBoard.BoardType_Id,
|
|
// Branch = x.DisputeResolutionBoard.Branch,
|
|
// DisputeResolutionPetitionDate = x.DisputeResolutionBoard.DisputeResolutionPetitionDate.ToFarsi(),
|
|
// ExpertReport = x.DisputeResolutionBoard.ExpertReport,
|
|
// File_Id = x.DisputeResolutionBoard.File_Id
|
|
// },
|
|
// DiagnosisPetition = x.DiagnosisPetition == null
|
|
// ? new EditPetition()
|
|
// : new EditPetition
|
|
// {
|
|
// Id = x.DiagnosisPetition.id,
|
|
// BoardType_Id = x.DiagnosisPetition.BoardType_Id,
|
|
// Description = x.DiagnosisPetition.Description,
|
|
// File_Id = x.DiagnosisPetition.File_Id,
|
|
// NotificationPetitionDate = x.DiagnosisPetition.NotificationPetitionDate.ToFarsi(),
|
|
// PetitionIssuanceDate = x.DiagnosisPetition.PetitionIssuanceDate.ToFarsi(),
|
|
// PetitionNo = x.DiagnosisPetition.PetitionNo,
|
|
// TotalPenalty = x.DiagnosisPetition.TotalPenalty,
|
|
// TotalPenaltyTitles = x.DiagnosisPetition.TotalPenaltyTitles,
|
|
// WorkHistoryDescription = x.DiagnosisPetition.WorkHistoryDescreption
|
|
// },
|
|
// DisputeResolutionPetition = x.DisputeResolutionPetition == null
|
|
// ? new EditPetition()
|
|
// : new EditPetition
|
|
// {
|
|
// Id = x.DisputeResolutionPetition.id,
|
|
// BoardType_Id = x.DisputeResolutionPetition.BoardType_Id,
|
|
// Description = x.DisputeResolutionPetition.Description,
|
|
// File_Id = x.DisputeResolutionPetition.File_Id,
|
|
// NotificationPetitionDate = x.DisputeResolutionPetition.NotificationPetitionDate.ToFarsi(),
|
|
// PetitionIssuanceDate = x.DisputeResolutionPetition.PetitionIssuanceDate.ToFarsi(),
|
|
// PetitionNo = x.DisputeResolutionPetition.PetitionNo,
|
|
// TotalPenalty = x.DisputeResolutionPetition.TotalPenalty,
|
|
// TotalPenaltyTitles = x.DisputeResolutionPetition.TotalPenaltyTitles,
|
|
// WorkHistoryDescription = x.DisputeResolutionPetition.WorkHistoryDescreption
|
|
// },
|
|
// DiagnosisEvidenceId = x.DiagnosisEvidence != null ? x.DiagnosisEvidence.id : 0,
|
|
// DisputeResolutionEvidenceId = x.DisputeResolutionEvidence != null ? x.DisputeResolutionEvidence.id : 0,
|
|
// DiagnosisMasterPetitionId = x.DiagnosisMasterPetition != null ? x.DiagnosisMasterPetition.id : 0,
|
|
// DisputeResolutionMasterPetitionId = x.DisputeResolutionMasterPetition != null ? x.DisputeResolutionMasterPetition.id : 0,
|
|
// FirstDiagnosisPS = x.FirstDiagnosisPS == null
|
|
// ? new EditProceedingSession()
|
|
// : new EditProceedingSession
|
|
// {
|
|
// Id = x.Id,
|
|
// Board_Id = x.FirstDiagnosisPS.Board_Id,
|
|
// Date = x.FirstDiagnosisPS.Date.ToFarsi(),
|
|
// Time = x.FirstDiagnosisPS.Time,
|
|
// Status = x.FirstDiagnosisPS.Status
|
|
// },
|
|
// LastDiagnosisPS = x.LastDiagnosisPS == null
|
|
// ? new EditProceedingSession()
|
|
// : new EditProceedingSession
|
|
// {
|
|
// Id = x.Id,
|
|
// Board_Id = x.LastDiagnosisPS.Board_Id,
|
|
// Date = x.LastDiagnosisPS.Date.ToFarsi(),
|
|
// Time = x.LastDiagnosisPS.Time,
|
|
// Status = x.LastDiagnosisPS.Status
|
|
// },
|
|
// FirstDisputeResolutionPS = x.FirstDisputeResolutionPS == null
|
|
// ? new EditProceedingSession()
|
|
// : new EditProceedingSession
|
|
// {
|
|
// Id = x.Id,
|
|
// Board_Id = x.FirstDisputeResolutionPS.Board_Id,
|
|
// Date = x.FirstDisputeResolutionPS.Date.ToFarsi(),
|
|
// Time = x.FirstDisputeResolutionPS.Time,
|
|
// Status = x.FirstDisputeResolutionPS.Status
|
|
// },
|
|
// LastDisputeResolutionPS = x.LastDisputeResolutionPS == null
|
|
// ? new EditProceedingSession()
|
|
// : new EditProceedingSession
|
|
// {
|
|
// Id = x.Id,
|
|
// Board_Id = x.LastDisputeResolutionPS.Board_Id,
|
|
// Date = x.LastDisputeResolutionPS.Date.ToFarsi(),
|
|
// Time = x.LastDisputeResolutionPS.Time,
|
|
// Status = x.LastDisputeResolutionPS.Status
|
|
// },
|
|
// DiagnosisPsCount = x.DiagnosisBoard != null ? x.DiagnosisBoard.ProceedingSessionsList.Count() : 0,
|
|
// DisputeResolutionPsCount = x.DisputeResolutionBoard != null ? x.DisputeResolutionBoard.ProceedingSessionsList.Count() : 0
|
|
//}).ToList();
|
|
|
|
//return result;
|
|
}
|
|
|
|
public long FindLastArchiveNumber()
|
|
{
|
|
var checkExist = _context.Files.Any();
|
|
long ArchiveNo = 0;
|
|
if (checkExist)
|
|
{
|
|
ArchiveNo = _context.Files.OrderByDescending(x => x.ArchiveNo).Select(x => x.ArchiveNo)
|
|
.FirstOrDefault();
|
|
}
|
|
|
|
return ArchiveNo;
|
|
}
|
|
|
|
public string GetEmployeeFullNameById(long id)
|
|
{
|
|
var result = _context.Employees.Where(x => x.id == id).Select(x => new EmployeeViewModel()
|
|
{
|
|
EmployeeFullName = x.FName + " " + x.LName
|
|
|
|
}).FirstOrDefault();
|
|
return result?.EmployeeFullName??"-";
|
|
}
|
|
|
|
public string GetEmployerFullNameById(long id)
|
|
{
|
|
var result = _context.Employers.Where(x => x.id == id).Select(x => new EmployerViewModel()
|
|
{
|
|
FullName = x.FullName
|
|
|
|
}).FirstOrDefault();
|
|
return result?.FullName??"-";
|
|
}
|
|
|
|
public List<EmployeeViewModel> GetAllEmploees()
|
|
{
|
|
//var query = _context.Files.Select(x => x.Reqester).ToList();
|
|
//query.AddRange(_context.Files.Select(x => x.Summoned).ToList());
|
|
|
|
//var query_1 = _context.Employees.Where(x=>x.IsActive).Select(x => new EmployeeViewModel()
|
|
//{
|
|
// Id = x.id,
|
|
// EmployeeFullName = x.FName + " " + x.LName,
|
|
|
|
//}).Where(x => query.Contains(x.Id));
|
|
|
|
//return query_1.ToList();
|
|
|
|
return _context.Employees.Where(x => x.IsActive).Select(x => new EmployeeViewModel()
|
|
{
|
|
Id = x.id,
|
|
EmployeeFullName = x.FName + " " + x.LName,
|
|
|
|
|
|
}).ToList();
|
|
|
|
}
|
|
|
|
public List<EmployerViewModel> GetAllEmployers()
|
|
{
|
|
return _context.Employers.Where(x => x.IsActive).Select(x => new EmployerViewModel()
|
|
{
|
|
Id = x.id,
|
|
FullName = x.FullName,
|
|
|
|
|
|
}).ToList();
|
|
}
|
|
|
|
public async Task<List<FileExcelViewModel>> GetExcelDetails()
|
|
{
|
|
var fileQuery = _context.Files.Include(x => x.PetitionsList).AsQueryable();
|
|
var requesterEmployeeQuery = await _context.Employees.Where(x => fileQuery.Any(f => f.Reqester == x.id)).ToListAsync();
|
|
var summonedEmployerQuery = await _context.Employers.Where(x => fileQuery.Any(f => f.Summoned == x.id)).ToListAsync();
|
|
|
|
var files = await fileQuery.ToListAsync();
|
|
|
|
var res = files.Select(x =>
|
|
{
|
|
var requester = requesterEmployeeQuery.FirstOrDefault(e => e.id == x.Reqester);
|
|
var summoned = summonedEmployerQuery.FirstOrDefault(e => e.id == x.Summoned);
|
|
|
|
return new FileExcelViewModel
|
|
{
|
|
ArchiveNumber = x.ArchiveNo,
|
|
FileClass = x.FileClass,
|
|
Client = x.Client == 1 ? requester?.FullName : summoned?.FullName ?? "-",
|
|
LitigationParty = x.Client == 1 ? summoned?.FullName : requester?.FullName ?? "-",
|
|
DiagnosisPetitionTotalPenalty =
|
|
x.PetitionsList.FirstOrDefault(p => p.BoardType_Id == 1)?.TotalPenalty ?? "-",
|
|
DisputeResolutionTotalPenalty = x.PetitionsList.FirstOrDefault(p => p.BoardType_Id == 2)?.TotalPenalty ?? "-",
|
|
MclsUsername = x.Client == 1 ? requester?.MclsUserName : summoned?.MclsUserName ?? "-",
|
|
MclsPassword = x.Client == 1 ? requester?.MclsPassword : summoned?.MclsPassword ?? "-",
|
|
Status = x.Status
|
|
};
|
|
}).OrderBy(x => x.Status == 1).ThenBy(x => x.Status == 3).ThenBy(x => x.Status == 2);
|
|
|
|
return res.ToList();
|
|
}
|
|
|
|
public async Task<List<FileListViewModel>> GetList(GetFileSearchModel searchModel)
|
|
{
|
|
|
|
var fileQuery = _context.Files.Include(x => x.PetitionsList).Include(x => x.BoardsList).ThenInclude(x => x.ProceedingSessionsList).AsQueryable();
|
|
|
|
#region Search
|
|
|
|
if (searchModel.Status > 0)
|
|
fileQuery = fileQuery.Where(x => x.Status == searchModel.Status);
|
|
if (searchModel.ArchiveNumber > 0)
|
|
{
|
|
fileQuery = fileQuery.Where(x => x.ArchiveNo == searchModel.ArchiveNumber);
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.FileClass))
|
|
{
|
|
fileQuery = fileQuery.Where(x => x.FileClass.Contains(searchModel.FileClass));
|
|
}
|
|
|
|
if (searchModel.ClientOrLitigationPartyId > 0)
|
|
{
|
|
|
|
fileQuery = fileQuery.Where(x => x.Reqester == searchModel.ClientOrLitigationPartyId || x.Summoned == searchModel.ClientOrLitigationPartyId);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.DiagnosisBoardBranch))
|
|
{
|
|
fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.Branch.Contains(searchModel.DiagnosisBoardBranch) && b.BoardType_Id == 1));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.DisputeResolutionBranch))
|
|
{
|
|
fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.Branch.Contains(searchModel.DisputeResolutionBranch) && b.BoardType_Id == 2));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.DiagnosisBoardChairMan))
|
|
{
|
|
fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.BoardChairman.Contains(searchModel.DiagnosisBoardChairMan) && b.BoardType_Id == 1));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.DisputeResolutionBoardChairMan))
|
|
{
|
|
fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.BoardChairman.Contains(searchModel.DisputeResolutionBoardChairMan) && b.BoardType_Id == 2));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.DiagnosisBoardFromDate))
|
|
{
|
|
var fromDate = searchModel.DiagnosisBoardFromDate.ToGeorgianDateTime();
|
|
fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.BoardType_Id == 1 && b.DisputeResolutionPetitionDate >= fromDate));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.DiagnosisBoardToDate))
|
|
{
|
|
var toDate = searchModel.DiagnosisBoardToDate.ToGeorgianDateTime();
|
|
fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.BoardType_Id == 1 && b.DisputeResolutionPetitionDate <= toDate));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.DisputeResolutionBoardFromDate))
|
|
{
|
|
var fromDate = searchModel.DisputeResolutionBoardFromDate.ToGeorgianDateTime();
|
|
fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.BoardType_Id == 2 && b.DisputeResolutionPetitionDate >= fromDate));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchModel.DisputeResolutionBoardToDate))
|
|
{
|
|
var toDate = searchModel.DisputeResolutionBoardToDate.ToGeorgianDateTime();
|
|
fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.BoardType_Id == 2 && b.DisputeResolutionPetitionDate <= toDate));
|
|
}
|
|
|
|
|
|
#endregion
|
|
fileQuery = fileQuery.Skip(searchModel.PageIndex).Take(30);
|
|
|
|
var requesterEmployeeQuery = await _context.Employees.Where(x => fileQuery.Any(f => f.Reqester == x.id)).ToListAsync();
|
|
var summonedEmployerQuery = await _context.Employers.Where(x => fileQuery.Any(f => f.Summoned == x.id)).ToListAsync();
|
|
|
|
var result = (await fileQuery.ToListAsync()).Select(x =>
|
|
{
|
|
var requester = requesterEmployeeQuery.FirstOrDefault(e => e.id == x.Reqester);
|
|
var summoned = summonedEmployerQuery.FirstOrDefault(e => e.id == x.Summoned);
|
|
var diagnosisBoard = x.BoardsList.FirstOrDefault(b => b.BoardType_Id == 1);
|
|
var disputeResolutionBoard = x.BoardsList.FirstOrDefault(b => b.BoardType_Id == 2);
|
|
var diagnosisPetition = x.PetitionsList.FirstOrDefault(p => p.BoardType_Id == 1);
|
|
var disputeResolutionPetition = x.PetitionsList.FirstOrDefault(p => p.BoardType_Id == 2);
|
|
return new FileListViewModel()
|
|
{
|
|
Id = x.id,
|
|
ArchiveNumber = x.ArchiveNo,
|
|
FileClass = x.FileClass,
|
|
Client = x.Client == 1 ? requester?.FullName : summoned?.FullName ?? "-",
|
|
LitigationParty = x.Client == 1 ? summoned?.FullName : requester?.FullName ?? "-",
|
|
Status = x.Status,
|
|
HasMandate = x.HasMandate,
|
|
DiagnosisBoard = new FileListBoardViewModel()
|
|
{
|
|
BoardChairman = diagnosisBoard?.BoardChairman ?? "-",
|
|
Branch = diagnosisBoard?.Branch ?? "-",
|
|
PetitionDate = diagnosisBoard?.DisputeResolutionPetitionDate.ToFarsi() ?? "-",
|
|
PetitionIssuanceDate = diagnosisPetition?.PetitionIssuanceDate.ToFarsi() ?? "-",
|
|
FirstResolutionPetitionDate =
|
|
diagnosisBoard?.ProceedingSessionsList.FirstOrDefault()?.Date.ToFarsi() ?? "-",
|
|
LastResolutionPetitionDate = diagnosisBoard?.ProceedingSessionsList.Count > 1
|
|
? diagnosisBoard.ProceedingSessionsList.Last().Date.ToFarsi()
|
|
: "-",
|
|
LastResolutionPetitionTurn = diagnosisBoard?.ProceedingSessionsList.Count > 1
|
|
? CharacterUtil.Convert((int)diagnosisBoard?.ProceedingSessionsList.Count)
|
|
: "-",
|
|
TotalPenalty = diagnosisPetition?.TotalPenalty ?? "-"
|
|
},
|
|
DisputeResolutionBoard = new FileListBoardViewModel()
|
|
{
|
|
BoardChairman = disputeResolutionBoard?.BoardChairman ?? "-",
|
|
Branch = disputeResolutionBoard?.Branch ?? "-",
|
|
PetitionDate = disputeResolutionBoard?.DisputeResolutionPetitionDate.ToFarsi() ?? "-",
|
|
PetitionIssuanceDate = disputeResolutionPetition?.PetitionIssuanceDate.ToFarsi() ?? "-",
|
|
FirstResolutionPetitionDate =
|
|
disputeResolutionBoard?.ProceedingSessionsList.FirstOrDefault()?.Date.ToFarsi() ?? "-",
|
|
LastResolutionPetitionDate = disputeResolutionBoard?.ProceedingSessionsList.Count > 1
|
|
? disputeResolutionBoard.ProceedingSessionsList.Last().Date.ToFarsi()
|
|
: "-",
|
|
LastResolutionPetitionTurn = disputeResolutionBoard?.ProceedingSessionsList.Count > 1
|
|
? CharacterUtil.Convert((int)disputeResolutionBoard?.ProceedingSessionsList.Count)
|
|
: "-",
|
|
TotalPenalty = disputeResolutionPetition?.TotalPenalty ?? "-"
|
|
}
|
|
|
|
};
|
|
}).ToList();
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
public async Task<List<string>> GetAllArchiveNo()
|
|
{
|
|
return await _context.Files.Select(x => x.ArchiveNo.ToString()).ToListAsync();
|
|
}
|
|
|
|
public async Task<List<string>> GetAllClassFiles()
|
|
{
|
|
return await _context.Files.Select(x => x.FileClass).Distinct().ToListAsync();
|
|
}
|
|
|
|
async Task<List<EmployeeSelectListViewModel>> IFileRepository.GetClientAndLitigation()
|
|
{
|
|
var files = _context.Files.AsQueryable();
|
|
|
|
var employees = await _context.Employees.Where(x => files.Any(f => f.Reqester == x.id)).Select(x => new EmployeeSelectListViewModel
|
|
{
|
|
Id = x.id,
|
|
EmployeeFullName = x.FName + " " + x.LName,
|
|
}).ToListAsync();
|
|
|
|
var employers = await _context.Employers.Where(x => files.Any(f => f.Summoned == x.id)).Select(x => new EmployeeSelectListViewModel
|
|
{
|
|
Id = x.id,
|
|
EmployeeFullName = x.FullName,
|
|
}).ToListAsync();
|
|
|
|
var result = employers.Concat(employees).ToList();
|
|
|
|
return result;
|
|
}
|
|
|
|
public async Task<EditEmployee> GetClientDetails(long fileId)
|
|
{
|
|
var file = await _context.Files.FirstOrDefaultAsync(x => x.id == fileId);
|
|
if (file == null)
|
|
return null;
|
|
|
|
EditEmployee result ;
|
|
if (file.Client == 1)
|
|
{
|
|
result = _context.Employees.Where(x => x.id == file.Reqester).Select(x => new EditEmployee
|
|
{
|
|
Id = x.id,
|
|
FName = x.FName,
|
|
LName = x.LName,
|
|
MclsUserName = x.MclsUserName,
|
|
MclsPassword = x.MclsPassword,
|
|
EserviceUserName = x.EserviceUserName,
|
|
EservicePassword = x.EservicePassword,
|
|
SanaUserName = x.SanaUserName,
|
|
SanaPassword = x.SanaPassword
|
|
}).FirstOrDefault();
|
|
}
|
|
else
|
|
{
|
|
result = _context.Employers.Where(x => x.id == file.Summoned).Select(x => new EditEmployee
|
|
{
|
|
Id = x.id,
|
|
FName = x.FName,
|
|
LName = x.LName,
|
|
MclsUserName = x.MclsUserName,
|
|
MclsPassword = x.MclsPassword,
|
|
EserviceUserName = x.EserviceUserName,
|
|
EservicePassword = x.EservicePassword,
|
|
SanaUserName = x.SanaUserName,
|
|
SanaPassword = x.SanaPassword
|
|
}).FirstOrDefault();
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
} |