diff --git a/Company.Domain/EmployeeDocumentsAgg/EmployeeDocuments.cs b/Company.Domain/EmployeeDocumentsAgg/EmployeeDocuments.cs index 65904a35..2889caab 100644 --- a/Company.Domain/EmployeeDocumentsAgg/EmployeeDocuments.cs +++ b/Company.Domain/EmployeeDocumentsAgg/EmployeeDocuments.cs @@ -54,11 +54,12 @@ namespace Company.Domain.EmployeeDocumentsAgg var currentItems = EmployeeDocumentItemCollection.Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted) .GroupBy(x => x.DocumentLabel).Select(x => x.OrderByDescending(y => y.CreationDate).First()); - var currentItemsFiltered = currentItems.Where(x => x.DocumentStatus == DocumentStatus.Confirmed || x.DocumentStatus == DocumentStatus.SubmittedByAdmin) - .Select(x => new{x.DocumentStatus,x.DocumentLabel}).ToList(); + var currentItemsFiltered = currentItems.Where(x => x.DocumentStatus is DocumentStatus.Confirmed or DocumentStatus.SubmittedByAdmin or DocumentStatus.SubmittedByClient) + .Select(x => new { x.DocumentStatus, x.DocumentLabel }).ToList(); + // ReSharper disable once SimplifyLinqExpressionUseAll - if (!currentItemsFiltered.Any(x => x.DocumentStatus == DocumentStatus.SubmittedByAdmin)) + if (!currentItemsFiltered.Any(x => x.DocumentStatus is DocumentStatus.SubmittedByAdmin or DocumentStatus.SubmittedByClient)) IsSentToChecker = false; else diff --git a/CompanyManagment.Application/EmployeeDocumentsApplication.cs b/CompanyManagment.Application/EmployeeDocumentsApplication.cs index ba698e5b..ad48936a 100644 --- a/CompanyManagment.Application/EmployeeDocumentsApplication.cs +++ b/CompanyManagment.Application/EmployeeDocumentsApplication.cs @@ -26,39 +26,39 @@ using Company.Domain.EmployeeClientTempAgg; namespace CompanyManagment.Application { - public class EmployeeDocumentsApplication : IEmployeeDocumentsApplication - { - private readonly IEmployeeDocumentsRepository _employeeDocumentsRepository; - private readonly IEmployeeRepository _employeeRepository; - private readonly IWorkshopRepository _workshopRepository; - private readonly IWebHostEnvironment _webHostEnvironment; - private readonly IMediaRepository _mediaRepository; - private readonly ILeftWorkRepository _leftWorkRepository; - private readonly IEmployeeDocumentItemRepository _employeeDocumentItemRepository; - private readonly IAuthHelper _authHelper; + public class EmployeeDocumentsApplication : IEmployeeDocumentsApplication + { + private readonly IEmployeeDocumentsRepository _employeeDocumentsRepository; + private readonly IEmployeeRepository _employeeRepository; + private readonly IWorkshopRepository _workshopRepository; + private readonly IWebHostEnvironment _webHostEnvironment; + private readonly IMediaRepository _mediaRepository; + private readonly ILeftWorkRepository _leftWorkRepository; + private readonly IEmployeeDocumentItemRepository _employeeDocumentItemRepository; + private readonly IAuthHelper _authHelper; private readonly IEmployeeClientTempRepository _employeeClientTempRepository; private readonly string _basePath; - public EmployeeDocumentsApplication(IEmployeeDocumentsRepository employeeDocumentsRepository, - IEmployeeRepository employeeRepository, - IWorkshopRepository workshopRepository, IWebHostEnvironment webHostEnvironment, - IMediaRepository mediaRepository, ILeftWorkRepository leftWorkRepository, - IEmployeeDocumentItemRepository employeeDocumentItemRepository, IAuthHelper authHelper, IEmployeeClientTempRepository employeeClientTempRepository) - { - _employeeDocumentsRepository = employeeDocumentsRepository; - _employeeRepository = employeeRepository; - _workshopRepository = workshopRepository; - _webHostEnvironment = webHostEnvironment; - _mediaRepository = mediaRepository; - _leftWorkRepository = leftWorkRepository; - _employeeDocumentItemRepository = employeeDocumentItemRepository; - _authHelper = authHelper; + public EmployeeDocumentsApplication(IEmployeeDocumentsRepository employeeDocumentsRepository, + IEmployeeRepository employeeRepository, + IWorkshopRepository workshopRepository, IWebHostEnvironment webHostEnvironment, + IMediaRepository mediaRepository, ILeftWorkRepository leftWorkRepository, + IEmployeeDocumentItemRepository employeeDocumentItemRepository, IAuthHelper authHelper, IEmployeeClientTempRepository employeeClientTempRepository) + { + _employeeDocumentsRepository = employeeDocumentsRepository; + _employeeRepository = employeeRepository; + _workshopRepository = workshopRepository; + _webHostEnvironment = webHostEnvironment; + _mediaRepository = mediaRepository; + _leftWorkRepository = leftWorkRepository; + _employeeDocumentItemRepository = employeeDocumentItemRepository; + _authHelper = authHelper; _employeeClientTempRepository = employeeClientTempRepository; _basePath = Path.Combine(_webHostEnvironment.ContentRootPath, "Storage", "EmployeeDocuments"); - } + } /// /// مدارک تا قبل از ثبت کردن می توانند توسط کاربر حذف شوند @@ -138,7 +138,7 @@ namespace CompanyManagment.Application } var currentItems = entity.EmployeeDocumentItemCollection.GroupBy(x => x.DocumentLabel) - .Select(x => x.MaxBy(y => y.CreationDate)).Where(x=>x.DocumentStatus == DocumentStatus.Unsubmitted); + .Select(x => x.MaxBy(y => y.CreationDate)).Where(x => x.DocumentStatus == DocumentStatus.Unsubmitted); //This can bite! _employeeDocumentItemRepository.RemoveRange(currentItems); @@ -304,24 +304,24 @@ namespace CompanyManagment.Application /// ثبت مدارک توسط کلاینت /// public OperationResult SubmitDocumentItemsByClient(SubmitEmployeeDocuments cmd) - { - OperationResult op = new(); - var entity = _employeeDocumentsRepository.GetByIdWithItems(cmd.EmployeeDocumentsId); - var currentDocs = entity.EmployeeDocumentItemCollection.GroupBy(x => x.DocumentLabel).Select(x => x.MaxBy(y => y.CreationDate)) + { + OperationResult op = new(); + var entity = _employeeDocumentsRepository.GetByIdWithItems(cmd.EmployeeDocumentsId); + var currentDocs = entity.EmployeeDocumentItemCollection.GroupBy(x => x.DocumentLabel).Select(x => x.MaxBy(y => y.CreationDate)) .ToList(); - var (userId, userType) = _authHelper.GetUserTypeWithId(); + var (userId, userType) = _authHelper.GetUserTypeWithId(); - var unsubmittedDocs = currentDocs.Where(x => x.DocumentStatus == DocumentStatus.Unsubmitted && + var unsubmittedDocs = currentDocs.Where(x => x.DocumentStatus == DocumentStatus.Unsubmitted && x.UploaderType == UserType.Client).ToList(); - if (unsubmittedDocs.Any() == false) - return op.Succcedded(); + if (unsubmittedDocs.Any() == false) + return op.Succcedded(); - foreach (var item in unsubmittedDocs) + foreach (var item in unsubmittedDocs) { item.SubmitByClient(userId, userType); MoveDocumentItemFile(item.MediaId, @@ -339,7 +339,7 @@ namespace CompanyManagment.Application _employeeDocumentsRepository.SaveChanges(); return op.Succcedded(); - } + } /// @@ -350,7 +350,7 @@ namespace CompanyManagment.Application OperationResult op = new(); var entity = _employeeDocumentsRepository.GetByEmployeeIdWorkshopIdWithItems(employeeId, workshopId); var notRejectedDocs = entity.EmployeeDocumentItemCollection - .Where(x=>x.DocumentStatus != DocumentStatus.Unsubmitted || x.UploaderType == UserType.Client) + .Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted || x.UploaderType == UserType.Client) .GroupBy(x => x.DocumentLabel).Select(x => x.MaxBy(y => y.CreationDate)).ToList(); if (!HasRequiredDocuments(notRejectedDocs, entity.Gender)) @@ -556,11 +556,11 @@ namespace CompanyManagment.Application var employee = _employeeRepository.Get(entity.EmployeeId); - var result= new EmployeeDocumentsViewModel() - { - Id = entity.id, - MilitaryServiceCard = GetItemFromCollectionByLabel(currentConfirmedDocuments, medias, - DocumentItemLabel.MilitaryServiceCard), + var result = new EmployeeDocumentsViewModel() + { + Id = entity.id, + MilitaryServiceCard = GetItemFromCollectionByLabel(currentConfirmedDocuments, medias, + DocumentItemLabel.MilitaryServiceCard), EducationalDegree = GetItemFromCollectionByLabel(currentConfirmedDocuments, medias, DocumentItemLabel.EducationalDegree), @@ -587,22 +587,22 @@ namespace CompanyManagment.Application EmployeePicture = GetItemFromCollectionByLabel(currentConfirmedDocuments, medias, DocumentItemLabel.EmployeePicture), - EmployeeFullName = employee.FullName, - WorkshopId = workshopId, - EmployeeId = entity.EmployeeId, - Gender = employee.Gender, - NationalCode = employee.NationalCode, - EmployeeFName = employee.FName, - EmployeeLName = employee.LName, - Nationality = employee.Nationality, - IdNumber = employee.IdNumber, - FatherName = employee.FatherName, - DateOfBirth = employee.DateOfBirth.ToFarsi(), - MaritalStatus = employee.MaritalStatus, - MilitaryServiceStatus = employee.MilitaryService, - SubmittedItemsCount = currentConfirmedDocuments.Count(x => x.DocumentStatus == DocumentStatus.SubmittedByAdmin || x.DocumentStatus == DocumentStatus.SubmittedByClient), - IsSentToChecker = entity.IsSentToChecker - }; + EmployeeFullName = employee.FullName, + WorkshopId = workshopId, + EmployeeId = entity.EmployeeId, + Gender = employee.Gender, + NationalCode = employee.NationalCode, + EmployeeFName = employee.FName, + EmployeeLName = employee.LName, + Nationality = employee.Nationality, + IdNumber = employee.IdNumber, + FatherName = employee.FatherName, + DateOfBirth = employee.DateOfBirth.ToFarsi(), + MaritalStatus = employee.MaritalStatus, + MilitaryServiceStatus = employee.MilitaryService, + SubmittedItemsCount = currentConfirmedDocuments.Count(x => x.DocumentStatus == DocumentStatus.SubmittedByAdmin || x.DocumentStatus == DocumentStatus.SubmittedByClient), + IsSentToChecker = entity.IsSentToChecker + }; result.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(result.EmployeePicture.PicturePath); result.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(result.IdCardPage1.PicturePath); result.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(result.IdCardPage2.PicturePath); @@ -615,12 +615,12 @@ namespace CompanyManagment.Application } - /// - /// جستجوی مجموعه مدارک بر اساس کارگاه - /// - /// مد تعیین کننده فیلتر افراد فعال است، سه حالت دارد: همه، فقط فعال، فقط غیر فعال - public List SearchForClient(SearchEmployeeDocuments cmd, EmployeeDocumentSearchMode mode=EmployeeDocumentSearchMode.ActiveEmployees) - { + /// + /// جستجوی مجموعه مدارک بر اساس کارگاه + /// + /// مد تعیین کننده فیلتر افراد فعال است، سه حالت دارد: همه، فقط فعال، فقط غیر فعال + public List SearchForClient(SearchEmployeeDocuments cmd, EmployeeDocumentSearchMode mode = EmployeeDocumentSearchMode.ActiveEmployees) + { #region Create EmployeeDocuments Record For Newly Added Employees @@ -712,7 +712,7 @@ namespace CompanyManagment.Application MoveDocumentItemFile(clientUploadedItem.MediaId, $"Deleted/{clientUploadedItem.EmployeeDocuments.WorkshopId}/{clientUploadedItem.EmployeeDocuments.EmployeeId}"); } } - DeleteMultipleUnsubmittedDocumentsByLabel(entity,label, uploaderType); + DeleteMultipleUnsubmittedDocumentsByLabel(entity, label, uploaderType); _employeeDocumentItemRepository.SaveChanges(); return op.Succcedded(); @@ -721,60 +721,60 @@ namespace CompanyManagment.Application /// ///حذف آیتم ثبت شده توسط کلاینت برای ادمین /// - public OperationResult RemoveClientDocumentItemsByAdmin(long workshopId,long employeeId,Listlabels) - { - OperationResult op = new(); + public OperationResult RemoveClientDocumentItemsByAdmin(long workshopId, long employeeId, List labels) + { + OperationResult op = new(); - var (uploaderId, uploaderType) = _authHelper.GetUserTypeWithId(); + var (uploaderId, uploaderType) = _authHelper.GetUserTypeWithId(); - if (!_employeeRepository.Exists(x => x.id == employeeId)) - return op.Failed("پرسنل یافت نشد"); + if (!_employeeRepository.Exists(x => x.id == employeeId)) + return op.Failed("پرسنل یافت نشد"); - if (!_workshopRepository.Exists(x => x.id == workshopId)) - return op.Failed("کارگاه وجود ندارد"); + if (!_workshopRepository.Exists(x => x.id == workshopId)) + return op.Failed("کارگاه وجود ندارد"); - var entity = - _employeeDocumentsRepository.GetByEmployeeIdWorkshopIdWithItems(employeeId, workshopId); + var entity = + _employeeDocumentsRepository.GetByEmployeeIdWorkshopIdWithItems(employeeId, workshopId); - if (entity == null) - { + if (entity == null) + { - return op.Failed("خطای سیستمی"); + return op.Failed("خطای سیستمی"); - } + } - var currentItems = entity.EmployeeDocumentItemCollection - .Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted || x.UploaderType == UserType.Admin) - .GroupBy(x => x.DocumentLabel).Select(x => x.OrderByDescending(y => y.CreationDate).First()).ToList(); + var currentItems = entity.EmployeeDocumentItemCollection + .Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted || x.UploaderType == UserType.Admin) + .GroupBy(x => x.DocumentLabel).Select(x => x.OrderByDescending(y => y.CreationDate).First()).ToList(); - if (currentItems.Any(x=>labels.Contains(x.DocumentLabel) && x.DocumentStatus == DocumentStatus.SubmittedByAdmin)) - return op.Failed("امکان ثبت دوباره مدارک تا بررسی مدارک ثبت شده فعلی وجود ندارد"); + if (currentItems.Any(x => labels.Contains(x.DocumentLabel) && x.DocumentStatus == DocumentStatus.SubmittedByAdmin)) + return op.Failed("امکان ثبت دوباره مدارک تا بررسی مدارک ثبت شده فعلی وجود ندارد"); - var targetEntites = currentItems.Where(x=>labels.Contains(x.DocumentLabel) && x.DocumentStatus == DocumentStatus.SubmittedByClient).ToList(); - //if the given label is uploaded by user, move it and soft delete it - if (targetEntites.Any()) - { - foreach (var clientUploadedItem in targetEntites) - { - clientUploadedItem.Delete(uploaderId, uploaderType); - - MoveDocumentItemFile(clientUploadedItem.MediaId, $"Deleted/{clientUploadedItem.EmployeeDocuments.WorkshopId}/{clientUploadedItem.EmployeeDocuments.EmployeeId}"); - } - _employeeDocumentItemRepository.SaveChanges(); - } - return op.Succcedded(); - } + var targetEntites = currentItems.Where(x => labels.Contains(x.DocumentLabel) && x.DocumentStatus == DocumentStatus.SubmittedByClient).ToList(); + //if the given label is uploaded by user, move it and soft delete it + if (targetEntites.Any()) + { + foreach (var clientUploadedItem in targetEntites) + { + clientUploadedItem.Delete(uploaderId, uploaderType); - /// - /// اضافه کردن آیتم جدید به مدارک برای ادمین - /// - public OperationResult AddEmployeeDocumentItemForAdmin(AddEmployeeDocumentItem command) + MoveDocumentItemFile(clientUploadedItem.MediaId, $"Deleted/{clientUploadedItem.EmployeeDocuments.WorkshopId}/{clientUploadedItem.EmployeeDocuments.EmployeeId}"); + } + _employeeDocumentItemRepository.SaveChanges(); + } + return op.Succcedded(); + } + + /// + /// اضافه کردن آیتم جدید به مدارک برای ادمین + /// + public OperationResult AddEmployeeDocumentItemForAdmin(AddEmployeeDocumentItem command) { OperationResult op = new(); @@ -808,13 +808,13 @@ namespace CompanyManagment.Application if (currentItems.Any(x => x.DocumentLabel == command.Label && x.DocumentStatus == DocumentStatus.SubmittedByAdmin)) return op.Failed("امکان ثبت دوباره مدارک تا بررسی مدارک ثبت شده فعلی وجود ندارد"); - //if a given label is uploaded by user, move it and soft delete it + //if a given label is uploaded by user, move it and soft delete it if (currentItems.Any(x => x.DocumentLabel == command.Label && x.DocumentStatus == DocumentStatus.SubmittedByClient)) { var clientUploadedItem = currentItems.First(x => x.DocumentLabel == command.Label && x.DocumentStatus == DocumentStatus.SubmittedByClient); - clientUploadedItem.Delete(uploaderId,uploaderType); + clientUploadedItem.Delete(uploaderId, uploaderType); MoveDocumentItemFile(clientUploadedItem.MediaId, $"Deleted/{clientUploadedItem.EmployeeDocuments.WorkshopId}/{clientUploadedItem.EmployeeDocuments.EmployeeId}"); } @@ -848,161 +848,161 @@ namespace CompanyManagment.Application /// ثبت مدارک توسط ادمین /// public OperationResult SubmitDocumentItemsByAdmin(SubmitEmployeeDocuments cmd) - { - OperationResult op = new(); - var entity = _employeeDocumentsRepository.GetByIdWithItems(cmd.EmployeeDocumentsId); - var currentDocs = entity.EmployeeDocumentItemCollection.Where(x=>x.DocumentStatus != DocumentStatus.Unsubmitted || x.UploaderType == UserType.Admin) - .GroupBy(x => x.DocumentLabel).Select(x => x.MaxBy(y => y.CreationDate)).ToList(); - //if (!HasRequiredDocuments(notRejectedDocs, entity.Gender)) - // return op.Failed("مدارک الزامی بارگذاری نشده اند"); + { + OperationResult op = new(); + var entity = _employeeDocumentsRepository.GetByIdWithItems(cmd.EmployeeDocumentsId); + var currentDocs = entity.EmployeeDocumentItemCollection.Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted || x.UploaderType == UserType.Admin) + .GroupBy(x => x.DocumentLabel).Select(x => x.MaxBy(y => y.CreationDate)).ToList(); + //if (!HasRequiredDocuments(notRejectedDocs, entity.Gender)) + // return op.Failed("مدارک الزامی بارگذاری نشده اند"); - var (userId, operatorType) = _authHelper.GetUserTypeWithId(); + var (userId, operatorType) = _authHelper.GetUserTypeWithId(); - var adminUnsubmittedDocs = currentDocs.Where(x => x.DocumentStatus == DocumentStatus.SubmittedByClient || + var adminUnsubmittedDocs = currentDocs.Where(x => x.DocumentStatus == DocumentStatus.SubmittedByClient || (x.DocumentStatus == DocumentStatus.Unsubmitted && x.UploaderType == UserType.Admin)).ToList(); //if (!HasRequiredDocuments(currentDocs, entity.Gender)) // return op.Failed("مدارک الزامی بارگذاری نشده اند"); if (adminUnsubmittedDocs.Any() == false) - return op.Succcedded(); + return op.Succcedded(); - foreach (var item in adminUnsubmittedDocs) + foreach (var item in adminUnsubmittedDocs) { item.SubmitByAdmin(userId, operatorType); MoveDocumentItemFile(item.MediaId, $"SubmittedByAdmin/{item.EmployeeDocuments.WorkshopId}/{item.EmployeeDocuments.EmployeeId}"); } - _employeeDocumentItemRepository.SaveChanges(); - entity.UpdateRequiredItemsSubmittedByClient(); + _employeeDocumentItemRepository.SaveChanges(); + entity.UpdateRequiredItemsSubmittedByClient(); entity.UpdateIsSentToChecker(); entity.UpdateIsConfirmed(); _employeeDocumentsRepository.SaveChanges(); return op.Succcedded(); - } + } - /// - /// ثبت مدارک توسط ادمین، در این متد مدارک الزامی اعتبار سنجی دارند - /// - public OperationResult SubmitDocumentItemsByAdminInWorkFlow(SubmitEmployeeDocuments cmd) - { - OperationResult op = new(); - var entity = _employeeDocumentsRepository.GetByIdWithItems(cmd.EmployeeDocumentsId); - var currentDocs = entity.EmployeeDocumentItemCollection.Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted || x.UploaderType == UserType.Admin) - .GroupBy(x => x.DocumentLabel).Select(x => x.MaxBy(y => y.CreationDate)).ToList(); - //if (!HasRequiredDocuments(notRejectedDocs, entity.Gender)) - // return op.Failed("مدارک الزامی بارگذاری نشده اند"); + /// + /// ثبت مدارک توسط ادمین، در این متد مدارک الزامی اعتبار سنجی دارند + /// + public OperationResult SubmitDocumentItemsByAdminInWorkFlow(SubmitEmployeeDocuments cmd) + { + OperationResult op = new(); + var entity = _employeeDocumentsRepository.GetByIdWithItems(cmd.EmployeeDocumentsId); + var currentDocs = entity.EmployeeDocumentItemCollection.Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted || x.UploaderType == UserType.Admin) + .GroupBy(x => x.DocumentLabel).Select(x => x.MaxBy(y => y.CreationDate)).ToList(); + //if (!HasRequiredDocuments(notRejectedDocs, entity.Gender)) + // return op.Failed("مدارک الزامی بارگذاری نشده اند"); - var (userId, operatorType) = _authHelper.GetUserTypeWithId(); + var (userId, operatorType) = _authHelper.GetUserTypeWithId(); - var adminUnsubmittedDocs = currentDocs.Where(x => x.DocumentStatus == DocumentStatus.SubmittedByClient || - (x.DocumentStatus == DocumentStatus.Unsubmitted && x.UploaderType == UserType.Admin)).ToList(); + var adminUnsubmittedDocs = currentDocs.Where(x => x.DocumentStatus == DocumentStatus.SubmittedByClient || + (x.DocumentStatus == DocumentStatus.Unsubmitted && x.UploaderType == UserType.Admin)).ToList(); - if (!HasRequiredDocuments(currentDocs, entity.Gender)) - return op.Failed("مدارک الزامی بارگذاری نشده اند"); + if (!HasRequiredDocuments(currentDocs, entity.Gender)) + return op.Failed("مدارک الزامی بارگذاری نشده اند"); - if (adminUnsubmittedDocs.Any() == false) - return op.Succcedded(); + if (adminUnsubmittedDocs.Any() == false) + return op.Succcedded(); - foreach (var item in adminUnsubmittedDocs) - { - item.SubmitByAdmin(userId, operatorType); - MoveDocumentItemFile(item.MediaId, $"SubmittedByAdmin/{item.EmployeeDocuments.WorkshopId}/{item.EmployeeDocuments.EmployeeId}"); - } + foreach (var item in adminUnsubmittedDocs) + { + item.SubmitByAdmin(userId, operatorType); + MoveDocumentItemFile(item.MediaId, $"SubmittedByAdmin/{item.EmployeeDocuments.WorkshopId}/{item.EmployeeDocuments.EmployeeId}"); + } - _employeeDocumentItemRepository.SaveChanges(); - entity.UpdateRequiredItemsSubmittedByClient(); - entity.UpdateIsSentToChecker(); - entity.UpdateIsConfirmed(); - _employeeDocumentsRepository.SaveChanges(); + _employeeDocumentItemRepository.SaveChanges(); + entity.UpdateRequiredItemsSubmittedByClient(); + entity.UpdateIsSentToChecker(); + entity.UpdateIsConfirmed(); + _employeeDocumentsRepository.SaveChanges(); - return op.Succcedded(); - } + return op.Succcedded(); + } - /// - /// کلاینت unsubmitted دریافت جزییات مدارک پرسنل برای ادمین بدون مدارک - /// - public EmployeeDocumentsViewModel GetDetailsForAdmin(long employeeId, long workshopId) - { - var entity = _employeeDocumentsRepository.GetByEmployeeIdWorkshopIdWithItems(employeeId, workshopId); + /// + /// کلاینت unsubmitted دریافت جزییات مدارک پرسنل برای ادمین بدون مدارک + /// + public EmployeeDocumentsViewModel GetDetailsForAdmin(long employeeId, long workshopId) + { + var entity = _employeeDocumentsRepository.GetByEmployeeIdWorkshopIdWithItems(employeeId, workshopId); - if (!_employeeRepository.Exists(x => x.id == employeeId)) - return new(); - if (!_workshopRepository.Exists(x => x.id == workshopId)) - return new(); + if (!_employeeRepository.Exists(x => x.id == employeeId)) + return new(); + if (!_workshopRepository.Exists(x => x.id == workshopId)) + return new(); - //if entity is null but employee exists, make a new empty entity for it - if (entity == null) - { - var opCreate = - Create(new CreateEmployeeDocuments() { EmployeeId = employeeId, WorkshopId = workshopId }); - if (opCreate.IsSuccedded == false) return new(); + //if entity is null but employee exists, make a new empty entity for it + if (entity == null) + { + var opCreate = + Create(new CreateEmployeeDocuments() { EmployeeId = employeeId, WorkshopId = workshopId }); + if (opCreate.IsSuccedded == false) return new(); - return new EmployeeDocumentsViewModel() { EmployeeId = employeeId }; - } + return new EmployeeDocumentsViewModel() { EmployeeId = employeeId }; + } - List currentDocuments = entity.EmployeeDocumentItemCollection - .Where(x => x.UploaderType == UserType.Admin || x.DocumentStatus != DocumentStatus.Unsubmitted) - .GroupBy(x => x.DocumentLabel) - .Select(x => x.MaxBy(y => y.CreationDate)).ToList(); + List currentDocuments = entity.EmployeeDocumentItemCollection + .Where(x => x.UploaderType == UserType.Admin || x.DocumentStatus != DocumentStatus.Unsubmitted) + .GroupBy(x => x.DocumentLabel) + .Select(x => x.MaxBy(y => y.CreationDate)).ToList(); - var medias = _mediaRepository - .GetMedias(currentDocuments.Select(x => x.MediaId) - .ToList()); + var medias = _mediaRepository + .GetMedias(currentDocuments.Select(x => x.MediaId) + .ToList()); - var employee = _employeeRepository.Get(entity.EmployeeId); + var employee = _employeeRepository.Get(entity.EmployeeId); - var result = new EmployeeDocumentsViewModel() - { - Id = entity.id, - MilitaryServiceCard = GetItemFromCollectionByLabel(currentDocuments, medias, - DocumentItemLabel.MilitaryServiceCard), + var result = new EmployeeDocumentsViewModel() + { + Id = entity.id, + MilitaryServiceCard = GetItemFromCollectionByLabel(currentDocuments, medias, + DocumentItemLabel.MilitaryServiceCard), - EducationalDegree = GetItemFromCollectionByLabel(currentDocuments, medias, - DocumentItemLabel.EducationalDegree), + EducationalDegree = GetItemFromCollectionByLabel(currentDocuments, medias, + DocumentItemLabel.EducationalDegree), - IdCardPage1 = - GetItemFromCollectionByLabel(currentDocuments, medias, DocumentItemLabel.IdCardPage1), + IdCardPage1 = + GetItemFromCollectionByLabel(currentDocuments, medias, DocumentItemLabel.IdCardPage1), - IdCardPage2 = - GetItemFromCollectionByLabel(currentDocuments, medias, DocumentItemLabel.IdCardPage2), + IdCardPage2 = + GetItemFromCollectionByLabel(currentDocuments, medias, DocumentItemLabel.IdCardPage2), - IdCardPage3 = - GetItemFromCollectionByLabel(currentDocuments, medias, DocumentItemLabel.IdCardPage3), + IdCardPage3 = + GetItemFromCollectionByLabel(currentDocuments, medias, DocumentItemLabel.IdCardPage3), - IdCardPage4 = - GetItemFromCollectionByLabel(currentDocuments, medias, DocumentItemLabel.IdCardPage4), + IdCardPage4 = + GetItemFromCollectionByLabel(currentDocuments, medias, DocumentItemLabel.IdCardPage4), - NationalCardFront = GetItemFromCollectionByLabel(currentDocuments, medias, - DocumentItemLabel.NationalCardFront), + NationalCardFront = GetItemFromCollectionByLabel(currentDocuments, medias, + DocumentItemLabel.NationalCardFront), - NationalCardRear = GetItemFromCollectionByLabel(currentDocuments, medias, - DocumentItemLabel.NationalCardRear), + NationalCardRear = GetItemFromCollectionByLabel(currentDocuments, medias, + DocumentItemLabel.NationalCardRear), - EmployeePicture = GetItemFromCollectionByLabel(currentDocuments, medias, - DocumentItemLabel.EmployeePicture), + EmployeePicture = GetItemFromCollectionByLabel(currentDocuments, medias, + DocumentItemLabel.EmployeePicture), - EmployeeFullName = employee.FullName, - WorkshopId = workshopId, - EmployeeId = entity.EmployeeId, - Gender = employee.Gender, - NationalCode = employee.NationalCode, - EmployeeFName = employee.FName, - EmployeeLName = employee.LName, - Nationality = employee.Nationality, - IdNumber = employee.IdNumber, - FatherName = employee.FatherName, - DateOfBirth = employee.DateOfBirth.ToFarsi(), - MaritalStatus = employee.MaritalStatus, - MilitaryServiceStatus = employee.MilitaryService, + EmployeeFullName = employee.FullName, + WorkshopId = workshopId, + EmployeeId = entity.EmployeeId, + Gender = employee.Gender, + NationalCode = employee.NationalCode, + EmployeeFName = employee.FName, + EmployeeLName = employee.LName, + Nationality = employee.Nationality, + IdNumber = employee.IdNumber, + FatherName = employee.FatherName, + DateOfBirth = employee.DateOfBirth.ToFarsi(), + MaritalStatus = employee.MaritalStatus, + MilitaryServiceStatus = employee.MilitaryService, - }; + }; result.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(result.EmployeePicture.PicturePath); result.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(result.IdCardPage1.PicturePath); result.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(result.IdCardPage2.PicturePath); @@ -1016,116 +1016,116 @@ namespace CompanyManagment.Application } - /// - /// جستجوی مجموعه مدارک بر اساس کارگاه برای ادمین - /// مد تعیین کننده فیلتر افراد فعال است، سه حالت دارد: همه، فقط فعال، فقط غیر فعال - public List SearchForAdmin(SearchEmployeeDocuments cmd, EmployeeDocumentSearchMode mode=EmployeeDocumentSearchMode.ActiveEmployees) - { + /// + /// جستجوی مجموعه مدارک بر اساس کارگاه برای ادمین + /// مد تعیین کننده فیلتر افراد فعال است، سه حالت دارد: همه، فقط فعال، فقط غیر فعال + public List SearchForAdmin(SearchEmployeeDocuments cmd, EmployeeDocumentSearchMode mode = EmployeeDocumentSearchMode.ActiveEmployees) + { - #region Create EmployeeDocuments Record For Newly Added Employees + #region Create EmployeeDocuments Record For Newly Added Employees - var existingEmployeesWithDocs = _employeeDocumentsRepository.GetEmployeeIds(cmd.WorkshopId); - var existingEmployeeIds = - _leftWorkRepository.GetAllEmployeeIdsInWorkshop(cmd.WorkshopId); + var existingEmployeesWithDocs = _employeeDocumentsRepository.GetEmployeeIds(cmd.WorkshopId); + var existingEmployeeIds = + _leftWorkRepository.GetAllEmployeeIdsInWorkshop(cmd.WorkshopId); - var newEmployeeIds = existingEmployeeIds.Except(existingEmployeesWithDocs).ToList(); + var newEmployeeIds = existingEmployeeIds.Except(existingEmployeesWithDocs).ToList(); - if (newEmployeeIds.Any()) - { - List employees = _employeeRepository.GetRangeByIds(newEmployeeIds).Select(x => - new EmployeeDocuments(x.id, cmd.WorkshopId, x.Gender)).ToList(); + if (newEmployeeIds.Any()) + { + List employees = _employeeRepository.GetRangeByIds(newEmployeeIds).Select(x => + new EmployeeDocuments(x.id, cmd.WorkshopId, x.Gender)).ToList(); - _employeeDocumentsRepository.AddRange(employees); - _employeeDocumentsRepository.SaveChanges(); - } + _employeeDocumentsRepository.AddRange(employees); + _employeeDocumentsRepository.SaveChanges(); + } - #endregion + #endregion - cmd.Mode = mode; + cmd.Mode = mode; - var result = _employeeDocumentsRepository.SearchForAdmin(cmd); + var result = _employeeDocumentsRepository.SearchForAdmin(cmd); - result.ForEach(x => - { - var requiredDocuments = EmployeeDocumentRequiredItems.GetByGender(x.Gender); - x.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(x.EmployeePicture.PicturePath); - x.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage1.PicturePath); - x.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage2.PicturePath); - x.IdCardPage3.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage3.PicturePath); - x.IdCardPage4.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage4.PicturePath); - x.NationalCardFront.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardFront.PicturePath); - x.NationalCardRear.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardRear.PicturePath); - x.MilitaryServiceCard.PicturePath = GetThumbnailPathFromFilePath(x.MilitaryServiceCard.PicturePath); - x.RequiredDocuments = requiredDocuments; - x.RequiredDocumentsUploaded = x.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(y => y.PropertyType == typeof(EmployeeDocumentItemViewModel)) - .Select(y => y.GetValue(x) as EmployeeDocumentItemViewModel).Where(y => y != null && !string.IsNullOrWhiteSpace(y.PicturePath) && - (y.Status is DocumentStatus.Confirmed or DocumentStatus.SubmittedByAdmin)).Select(y => y.DocumentItemLabel).ToList(); - }); - return result; - } + result.ForEach(x => + { + var requiredDocuments = EmployeeDocumentRequiredItems.GetByGender(x.Gender); + x.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(x.EmployeePicture.PicturePath); + x.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage1.PicturePath); + x.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage2.PicturePath); + x.IdCardPage3.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage3.PicturePath); + x.IdCardPage4.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage4.PicturePath); + x.NationalCardFront.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardFront.PicturePath); + x.NationalCardRear.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardRear.PicturePath); + x.MilitaryServiceCard.PicturePath = GetThumbnailPathFromFilePath(x.MilitaryServiceCard.PicturePath); + x.RequiredDocuments = requiredDocuments; + x.RequiredDocumentsUploaded = x.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(y => y.PropertyType == typeof(EmployeeDocumentItemViewModel)) + .Select(y => y.GetValue(x) as EmployeeDocumentItemViewModel).Where(y => y != null && !string.IsNullOrWhiteSpace(y.PicturePath) && + (y.Status is DocumentStatus.Confirmed or DocumentStatus.SubmittedByAdmin)).Select(y => y.DocumentItemLabel).ToList(); + }); + return result; + } - /// - /// مجموعه مدارک بر اساس کارگاه برای کارپوشه ادمین - public List GetByWorkshopIdWithItemsForAdminWorkFlow(long workshopId) - { + /// + /// مجموعه مدارک بر اساس کارگاه برای کارپوشه ادمین + public List GetByWorkshopIdWithItemsForAdminWorkFlow(long workshopId) + { - #region Create EmployeeDocuments Record For Newly Added Employees + #region Create EmployeeDocuments Record For Newly Added Employees - var existingEmployeesWithDocs = _employeeDocumentsRepository.GetEmployeeIds(workshopId); - var existingEmployeeIds = - _leftWorkRepository.GetAllEmployeeIdsInWorkshop(workshopId); - var newEmployeeIds = existingEmployeeIds.Except(existingEmployeesWithDocs).ToList(); + var existingEmployeesWithDocs = _employeeDocumentsRepository.GetEmployeeIds(workshopId); + var existingEmployeeIds = + _leftWorkRepository.GetAllEmployeeIdsInWorkshop(workshopId); + var newEmployeeIds = existingEmployeeIds.Except(existingEmployeesWithDocs).ToList(); - if (newEmployeeIds.Any()) - { - List employees = _employeeRepository.GetRangeByIds(newEmployeeIds).Select(x => - new EmployeeDocuments(x.id, workshopId, x.Gender)).ToList(); + if (newEmployeeIds.Any()) + { + List employees = _employeeRepository.GetRangeByIds(newEmployeeIds).Select(x => + new EmployeeDocuments(x.id, workshopId, x.Gender)).ToList(); - _employeeDocumentsRepository.AddRange(employees); - _employeeDocumentsRepository.SaveChanges(); - } + _employeeDocumentsRepository.AddRange(employees); + _employeeDocumentsRepository.SaveChanges(); + } - #endregion + #endregion - var result = _employeeDocumentsRepository.GetByWorkshopIdWithItemsForAdminWorkFlow(workshopId); + var result = _employeeDocumentsRepository.GetByWorkshopIdWithItemsForAdminWorkFlow(workshopId); - result.ForEach(x => - { - var requiredDocuments = EmployeeDocumentRequiredItems.GetByGender(x.Gender); - x.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(x.EmployeePicture.PicturePath); - x.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage1.PicturePath); - x.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage2.PicturePath); - x.IdCardPage3.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage3.PicturePath); - x.IdCardPage4.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage4.PicturePath); - x.NationalCardFront.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardFront.PicturePath); - x.NationalCardRear.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardRear.PicturePath); - x.MilitaryServiceCard.PicturePath = GetThumbnailPathFromFilePath(x.MilitaryServiceCard.PicturePath); - x.RequiredDocuments = requiredDocuments; + result.ForEach(x => + { + var requiredDocuments = EmployeeDocumentRequiredItems.GetByGender(x.Gender); + x.EmployeePicture.PicturePath = GetThumbnailPathFromFilePath(x.EmployeePicture.PicturePath); + x.IdCardPage1.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage1.PicturePath); + x.IdCardPage2.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage2.PicturePath); + x.IdCardPage3.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage3.PicturePath); + x.IdCardPage4.PicturePath = GetThumbnailPathFromFilePath(x.IdCardPage4.PicturePath); + x.NationalCardFront.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardFront.PicturePath); + x.NationalCardRear.PicturePath = GetThumbnailPathFromFilePath(x.NationalCardRear.PicturePath); + x.MilitaryServiceCard.PicturePath = GetThumbnailPathFromFilePath(x.MilitaryServiceCard.PicturePath); + x.RequiredDocuments = requiredDocuments; - #region شتر دیدی ندیدی + #region شتر دیدی ندیدی - x.RequiredDocumentsUploaded = x.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(y => y.PropertyType == typeof(EmployeeDocumentItemViewModel)) - .Select(y => y.GetValue(x) as EmployeeDocumentItemViewModel).Where(y => y != null && !string.IsNullOrWhiteSpace(y.PicturePath) && - (y.Status is DocumentStatus.Confirmed or DocumentStatus.SubmittedByAdmin)).Select(y => y.DocumentItemLabel).ToList(); - #endregion - }); - return result; - } + x.RequiredDocumentsUploaded = x.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(y => y.PropertyType == typeof(EmployeeDocumentItemViewModel)) + .Select(y => y.GetValue(x) as EmployeeDocumentItemViewModel).Where(y => y != null && !string.IsNullOrWhiteSpace(y.PicturePath) && + (y.Status is DocumentStatus.Confirmed or DocumentStatus.SubmittedByAdmin)).Select(y => y.DocumentItemLabel).ToList(); + #endregion + }); + return result; + } - /// - /// دریافت کارگاه های ادمین که نیاز به آپلود مدارک ضروری دارند - /// - public List GetWorkshopDocumentsAwaitingUploadForAdminWorkFlow(List workshops) - { - return _employeeDocumentsRepository.GetWorkshopsWithDocumentsAwaitingReviewForAdminWorkFlow(workshops); - } + /// + /// دریافت کارگاه های ادمین که نیاز به آپلود مدارک ضروری دارند + /// + public List GetWorkshopDocumentsAwaitingUploadForAdminWorkFlow(List workshops) + { + return _employeeDocumentsRepository.GetWorkshopsWithDocumentsAwaitingReviewForAdminWorkFlow(workshops); + } - /// - /// حذف توسط ادمین، مدارک ثبت شده کلاینت نیز میتوانند توسط ادمین پاک شوند - /// + /// + /// حذف توسط ادمین، مدارک ثبت شده کلاینت نیز میتوانند توسط ادمین پاک شوند + /// public OperationResult RemoveByAdmin(long documentItemId) { OperationResult op = new(); @@ -1144,7 +1144,7 @@ namespace CompanyManagment.Application if (entity.UploaderType == UserType.Client) { - entity.Delete(operatorId,UserType.Admin); + entity.Delete(operatorId, UserType.Admin); } else @@ -1152,13 +1152,13 @@ namespace CompanyManagment.Application _employeeDocumentItemRepository.Remove(entity); } - _employeeDocumentItemRepository.SaveChanges(); + _employeeDocumentItemRepository.SaveChanges(); return op.Succcedded(); } public async Task GetAdminWorkFlowCountForSubmittedAndRejectedDocuments(List workshopIds) { - return await _employeeDocumentsRepository.GetAdminWorkFlowCountForSubmittedAndRejectedDocuments(workshopIds); + return await _employeeDocumentsRepository.GetAdminWorkFlowCountForSubmittedAndRejectedDocuments(workshopIds); } public async Task GetAdminWorkFlowCountForNewEmployees(List workshopIds) { @@ -1191,7 +1191,7 @@ namespace CompanyManagment.Application (long operatorId, UserType userType) = _authHelper.GetUserTypeWithId(); - if (item.DocumentStatus != DocumentStatus.SubmittedByAdmin) + if ((item.DocumentStatus is DocumentStatus.SubmittedByAdmin or DocumentStatus.SubmittedByClient) == false) return op.Failed("امکان بررسی رکورد مورد نظر وجود ندارد"); @@ -1261,8 +1261,7 @@ namespace CompanyManagment.Application .Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted) .GroupBy(x => x.DocumentLabel) .Select(x => x.MaxBy(y => y.CreationDate)) - .Where(x => x.DocumentStatus == DocumentStatus.SubmittedByAdmin || - x.DocumentStatus == DocumentStatus.Confirmed || x.DocumentStatus == DocumentStatus.Rejected).ToList(); + .Where(x => x.DocumentStatus is DocumentStatus.SubmittedByAdmin or DocumentStatus.Confirmed or DocumentStatus.Rejected or DocumentStatus.SubmittedByClient).ToList(); var medias = _mediaRepository @@ -1318,7 +1317,7 @@ namespace CompanyManagment.Application DateOfBirth = employee.DateOfBirth.ToFarsi(), MaritalStatus = employeeClientTemp == null ? employee.MaritalStatus : employeeClientTemp.MaritalStatus, MilitaryServiceStatus = employee.MilitaryService, - SubmittedItemsCount = currentDocuments.Count(x => x.DocumentStatus == DocumentStatus.SubmittedByAdmin) + SubmittedItemsCount = currentDocuments.Count(x => x.DocumentStatus is DocumentStatus.SubmittedByAdmin or DocumentStatus.SubmittedByClient) }; } @@ -1326,9 +1325,9 @@ namespace CompanyManagment.Application /// دریافت کارگاه هایی که اقدام به آپلود مدارک کرده اند /// public List GetWorkshopsWithUploadedDocumentsForChecker() - { - return _employeeDocumentsRepository.GetWorkshopsWithUploadedDocuments(); - } + { + return _employeeDocumentsRepository.GetWorkshopsWithUploadedDocuments(); + } /// /// دریافت پرسنلی که اقدام به آپلود مدارک کرده اند @@ -1356,13 +1355,13 @@ namespace CompanyManagment.Application /// دریافت کارگاه هایی که اقدام به آپلود مدارک "ضروری" کرده اند، برای کارپوشه /// public List GetWorkshopsWithDocumentsAwaitingReviewForCheckerWorkFlow() - { - return _employeeDocumentsRepository.GetWorkshopsWithDocumentsAwaitingReviewForCheckerWorkFlow(); - } + { + return _employeeDocumentsRepository.GetWorkshopsWithDocumentsAwaitingReviewForCheckerWorkFlow(); + } - /// - /// دریافت پرسنلی در کارگاه که مدارک ضروری آن ها آپلود شده ولی تایید یا رد نشده اند، برای کارپوشه - /// + /// + /// دریافت پرسنلی در کارگاه که مدارک ضروری آن ها آپلود شده ولی تایید یا رد نشده اند، برای کارپوشه + /// public List GetDocumentsAwaitingReviewByWorkshopIdForCheckerWorkFlow(long workshopId) { @@ -1471,286 +1470,286 @@ namespace CompanyManagment.Application /// مدارک ثبت نشده با برچسب داده شده را پاک می کند. هنگامی استفاده می شود که کاربر یک آیتم را آپلود می کند /// private void DeleteMultipleUnsubmittedDocumentsByLabel(EmployeeDocuments includedEmployeeDocuments, - DocumentItemLabel label,UserType userType) - { - var items = includedEmployeeDocuments.EmployeeDocumentItemCollection - .Where(x => x.DocumentStatus == DocumentStatus.Unsubmitted && x.DocumentLabel == label && x.UploaderType == userType).ToList(); + DocumentItemLabel label, UserType userType) + { + var items = includedEmployeeDocuments.EmployeeDocumentItemCollection + .Where(x => x.DocumentStatus == DocumentStatus.Unsubmitted && x.DocumentLabel == label && x.UploaderType == userType).ToList(); - var mediaIds = items.Select(x => x.MediaId); - if (items.Any()) - { - DeleteMultipleDocumentItemFiles(mediaIds); - _employeeDocumentItemRepository.RemoveRange(items); - _employeeDocumentItemRepository.SaveChanges(); - } + var mediaIds = items.Select(x => x.MediaId); + if (items.Any()) + { + DeleteMultipleDocumentItemFiles(mediaIds); + _employeeDocumentItemRepository.RemoveRange(items); + _employeeDocumentItemRepository.SaveChanges(); + } - } - /// - /// مدارک ثبت نشده با برچسب داده شده را پاک می کند. هنگامی استفاده می شود که کاربر یک آیتم را آپلود می کند - /// - private void DeleteMultipleUnsubmittedDocumentsByLabel(EmployeeDocuments includedEmployeeDocuments, - List labels, UserType userType) - { - var items = includedEmployeeDocuments.EmployeeDocumentItemCollection - .Where(x => x.DocumentStatus == DocumentStatus.Unsubmitted && labels.Contains(x.DocumentLabel) && x.UploaderType == userType).ToList(); + } + /// + /// مدارک ثبت نشده با برچسب داده شده را پاک می کند. هنگامی استفاده می شود که کاربر یک آیتم را آپلود می کند + /// + private void DeleteMultipleUnsubmittedDocumentsByLabel(EmployeeDocuments includedEmployeeDocuments, + List labels, UserType userType) + { + var items = includedEmployeeDocuments.EmployeeDocumentItemCollection + .Where(x => x.DocumentStatus == DocumentStatus.Unsubmitted && labels.Contains(x.DocumentLabel) && x.UploaderType == userType).ToList(); - var mediaIds = items.Select(x => x.MediaId); - if (items.Any()) - { - DeleteMultipleDocumentItemFiles(mediaIds); - _employeeDocumentItemRepository.RemoveRange(items); - _employeeDocumentItemRepository.SaveChanges(); - } - } + var mediaIds = items.Select(x => x.MediaId); + if (items.Any()) + { + DeleteMultipleDocumentItemFiles(mediaIds); + _employeeDocumentItemRepository.RemoveRange(items); + _employeeDocumentItemRepository.SaveChanges(); + } + } - //You don't need this method to be public as it's already called where its necessary - private OperationResult Create(CreateEmployeeDocuments command) + //You don't need this method to be public as it's already called where its necessary + private OperationResult Create(CreateEmployeeDocuments command) { OperationResult op = new(); if (!_employeeRepository.Exists(x => x.id == command.EmployeeId)) return op.Failed("پرسنل یافت نشد"); - if (!_workshopRepository.Exists(x => x.id == command.WorkshopId)) - return op.Failed("کارگاه وجود ندارد"); + if (!_workshopRepository.Exists(x => x.id == command.WorkshopId)) + return op.Failed("کارگاه وجود ندارد"); - // اگر در دیتابیس وجود داشت ارور ندهد و عملیاتی انجام ندهد - if (_employeeDocumentsRepository.Exists(x => x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId)) - return op.Succcedded(_employeeDocumentsRepository - .GetByEmployeeIdWorkshopId(command.EmployeeId, command.WorkshopId).id); + // اگر در دیتابیس وجود داشت ارور ندهد و عملیاتی انجام ندهد + if (_employeeDocumentsRepository.Exists(x => x.EmployeeId == command.EmployeeId && x.WorkshopId == command.WorkshopId)) + return op.Succcedded(_employeeDocumentsRepository + .GetByEmployeeIdWorkshopId(command.EmployeeId, command.WorkshopId).id); - var gender = _employeeRepository.Get(command.EmployeeId).Gender; - var entity = new EmployeeDocuments(command.EmployeeId, command.WorkshopId, gender); + var gender = _employeeRepository.Get(command.EmployeeId).Gender; + var entity = new EmployeeDocuments(command.EmployeeId, command.WorkshopId, gender); - _employeeDocumentsRepository.Create(entity); - _employeeDocumentsRepository.SaveChanges(); + _employeeDocumentsRepository.Create(entity); + _employeeDocumentsRepository.SaveChanges(); - return op.Succcedded(entity.id); - } + return op.Succcedded(entity.id); + } - /// - /// برای حذف فایل مدارک - /// - private OperationResult DeleteMultipleDocumentItemFiles(IEnumerable mediaIds) - { - OperationResult op = new(); - var medias = _mediaRepository.GetRange(mediaIds); - if (medias == null || !medias.Any()) - return op.Failed("رسانه مورد نظر یافت نشد"); + /// + /// برای حذف فایل مدارک + /// + private OperationResult DeleteMultipleDocumentItemFiles(IEnumerable mediaIds) + { + OperationResult op = new(); + var medias = _mediaRepository.GetRange(mediaIds); + if (medias == null || !medias.Any()) + return op.Failed("رسانه مورد نظر یافت نشد"); - foreach (var media in medias) - { + foreach (var media in medias) + { - var filePath = media.Path; - var thumbnailPath = GetThumbnailPathFromFilePath(filePath); - try - { - if (System.IO.File.Exists(filePath)) - System.IO.File.Delete(filePath); + var filePath = media.Path; + var thumbnailPath = GetThumbnailPathFromFilePath(filePath); + try + { + if (System.IO.File.Exists(filePath)) + System.IO.File.Delete(filePath); - if (System.IO.File.Exists(thumbnailPath)) - System.IO.File.Delete(thumbnailPath); + if (System.IO.File.Exists(thumbnailPath)) + System.IO.File.Delete(thumbnailPath); - } - catch - { - // ignored - } - } + } + catch + { + // ignored + } + } - _mediaRepository.RemoveRange(medias); - _mediaRepository.SaveChanges(); - //if (somethingWentWrong) - // return op.Failed("خطایی در حذف فایل رخ داده است"); - return op.Succcedded(); - } + _mediaRepository.RemoveRange(medias); + _mediaRepository.SaveChanges(); + //if (somethingWentWrong) + // return op.Failed("خطایی در حذف فایل رخ داده است"); + return op.Succcedded(); + } - /// - /// برای حذف فایل یکی از مدارک - /// - private OperationResult DeleteDocumentItemFile(long mediaId) - { - OperationResult op = new(); - var media = _mediaRepository.Get(mediaId); - if (media == null) - return op.Failed("رسانه مورد نظر یافت نشد"); - var filePath = media.Path; - var thumbnailPath = GetThumbnailPathFromFilePath(filePath); - try - { - if (System.IO.File.Exists(filePath)) - System.IO.File.Delete(filePath); + /// + /// برای حذف فایل یکی از مدارک + /// + private OperationResult DeleteDocumentItemFile(long mediaId) + { + OperationResult op = new(); + var media = _mediaRepository.Get(mediaId); + if (media == null) + return op.Failed("رسانه مورد نظر یافت نشد"); + var filePath = media.Path; + var thumbnailPath = GetThumbnailPathFromFilePath(filePath); + try + { + if (System.IO.File.Exists(filePath)) + System.IO.File.Delete(filePath); - if (System.IO.File.Exists(thumbnailPath)) - System.IO.File.Delete(thumbnailPath); + if (System.IO.File.Exists(thumbnailPath)) + System.IO.File.Delete(thumbnailPath); - } - catch - { - return op.Failed("خطایی در حذف فایل رخ داده است"); - } + } + catch + { + return op.Failed("خطایی در حذف فایل رخ داده است"); + } - _mediaRepository.Remove(media.id); - _mediaRepository.SaveChanges(); - return op.Succcedded(); - } + _mediaRepository.Remove(media.id); + _mediaRepository.SaveChanges(); + return op.Succcedded(); + } - /// - /// جابجا کردن فایل یکی از مدارک، استفاده شده هنگام تایید و رد - /// - private OperationResult MoveDocumentItemFile(long mediaId, string newRelativePath) - { - OperationResult op = new(); - var media = _mediaRepository.Get(mediaId); + /// + /// جابجا کردن فایل یکی از مدارک، استفاده شده هنگام تایید و رد + /// + private OperationResult MoveDocumentItemFile(long mediaId, string newRelativePath) + { + OperationResult op = new(); + var media = _mediaRepository.Get(mediaId); - var oldFilePath = media.Path; - var oldThumbnailPath = GetThumbnailPathFromFilePath(oldFilePath); + var oldFilePath = media.Path; + var oldThumbnailPath = GetThumbnailPathFromFilePath(oldFilePath); - var newDirectory = Path.Combine(_basePath, newRelativePath); - Directory.CreateDirectory(newDirectory); + var newDirectory = Path.Combine(_basePath, newRelativePath); + Directory.CreateDirectory(newDirectory); - string newFilePath = Path.Combine(newDirectory, Path.GetFileName(oldFilePath)!); - string newThumbnailFilePath = Path.Combine(newDirectory, Path.GetFileName(oldThumbnailPath)); + string newFilePath = Path.Combine(newDirectory, Path.GetFileName(oldFilePath)!); + string newThumbnailFilePath = Path.Combine(newDirectory, Path.GetFileName(oldThumbnailPath)); - try - { + try + { System.IO.File.Move(oldFilePath, newFilePath); System.IO.File.Move(oldThumbnailPath, newThumbnailFilePath); - } + } - catch - { - return op.Failed("در جابجایی فایل خطایی رخ داده است"); - } + catch + { + return op.Failed("در جابجایی فایل خطایی رخ داده است"); + } - media.Edit(newFilePath, media.Type, media.Category); - _mediaRepository.SaveChanges(); - return op.Succcedded(); - } + media.Edit(newFilePath, media.Type, media.Category); + _mediaRepository.SaveChanges(); + return op.Succcedded(); + } - /// - /// دریافت فایل و نوشتن آن در مسیر داده شده، و ثبت مدیا - /// - /// فایل - /// برچسب مدارک - /// مسیر فایل - /// - private OperationResult UploadDocumentItemFile(IFormFile file, string label, string relativePath) - { - OperationResult op = new(); - var now= DateTime.Now; + /// + /// دریافت فایل و نوشتن آن در مسیر داده شده، و ثبت مدیا + /// + /// فایل + /// برچسب مدارک + /// مسیر فایل + /// + private OperationResult UploadDocumentItemFile(IFormFile file, string label, string relativePath) + { + OperationResult op = new(); + var now = DateTime.Now; PersianCalendar pc = new PersianCalendar(); var yearFa = pc.GetYear(now); - var monthFa = pc.GetMonth(now); + var monthFa = pc.GetMonth(now); var dayFa = pc.GetDayOfMonth(now); var ticks = now.Ticks % 864_000_000_000; - List allowedExtensions = [".png", ".jpg", ".jpeg"]; - var path = Path.Combine(_basePath, relativePath); - var fileExtension = Path.GetExtension(file.FileName); + List allowedExtensions = [".png", ".jpg", ".jpeg"]; + var path = Path.Combine(_basePath, relativePath); + var fileExtension = Path.GetExtension(file.FileName); if (file.Length > (50 * 1024 * 1024)) return op.Failed("حجم فایل نمی تواند بیشتر از 50 مگابایت باشد"); - if (!allowedExtensions.Contains(fileExtension)) - { - var operationMessage = ":فرمت فایل باید یکی از موارد زیر باشد"; - operationMessage += "\n"; - operationMessage += string.Join(" ", allowedExtensions); - return op.Failed(operationMessage); - } + if (!allowedExtensions.Contains(fileExtension)) + { + var operationMessage = ":فرمت فایل باید یکی از موارد زیر باشد"; + operationMessage += "\n"; + operationMessage += string.Join(" ", allowedExtensions); + return op.Failed(operationMessage); + } - Directory.CreateDirectory(path); + Directory.CreateDirectory(path); - var type = Path.GetExtension(file.FileName); + var type = Path.GetExtension(file.FileName); - var uniqueFileName = $"{label}-{yearFa}-{monthFa}-{dayFa}-{ticks}{type}"; - var filePath = Path.Combine(path, uniqueFileName); - using (var fileStream = new FileStream(filePath, FileMode.CreateNew)) - { - file.CopyTo(fileStream); - } - #region Thumbnail Creation + var uniqueFileName = $"{label}-{yearFa}-{monthFa}-{dayFa}-{ticks}{type}"; + var filePath = Path.Combine(path, uniqueFileName); + using (var fileStream = new FileStream(filePath, FileMode.CreateNew)) + { + file.CopyTo(fileStream); + } + #region Thumbnail Creation - var uniqueFileNameThumbnail = $"{label}-{yearFa}-{monthFa}-{dayFa}-{ticks}-thumbnail{type}"; - var thumbnailFilePath = Path.Combine(path, uniqueFileNameThumbnail); - var thumbnail = Tools.ResizeImage(filePath, 150, 150); - System.IO.File.WriteAllBytes(thumbnailFilePath, Convert.FromBase64String(thumbnail)); - #endregion + var uniqueFileNameThumbnail = $"{label}-{yearFa}-{monthFa}-{dayFa}-{ticks}-thumbnail{type}"; + var thumbnailFilePath = Path.Combine(path, uniqueFileNameThumbnail); + var thumbnail = Tools.ResizeImage(filePath, 150, 150); + System.IO.File.WriteAllBytes(thumbnailFilePath, Convert.FromBase64String(thumbnail)); + #endregion - var mediaEntity = new Media(filePath, type, "فایل", "EmployeeDocuments"); + var mediaEntity = new Media(filePath, type, "فایل", "EmployeeDocuments"); - _mediaRepository.Create(mediaEntity); - _mediaRepository.SaveChanges(); + _mediaRepository.Create(mediaEntity); + _mediaRepository.SaveChanges(); - return op.Succcedded(mediaEntity.id); + return op.Succcedded(mediaEntity.id); - } + } - //private OperationResult UploadExistingRollCallEmployeePicture(long mediaId, long workshopId, long employeeId) - //{ - // OperationResult op = new(); - // var media = _mediaRepository.Get(mediaId); + //private OperationResult UploadExistingRollCallEmployeePicture(long mediaId, long workshopId, long employeeId) + //{ + // OperationResult op = new(); + // var media = _mediaRepository.Get(mediaId); - // if (media == null) - // return op.Failed("فایل مورد نظر یافت نشد"); + // if (media == null) + // return op.Failed("فایل مورد نظر یافت نشد"); - // var path = Path.Combine(_webHostEnvironment.ContentRootPath, "Storage", "EmployeeDocuments", "temp", - // $"{workshopId}", $"{employeeId}"); + // var path = Path.Combine(_webHostEnvironment.ContentRootPath, "Storage", "EmployeeDocuments", "temp", + // $"{workshopId}", $"{employeeId}"); - // var uniqueFileName = $"{DocumentItemLabel.EmployeePicture.ToString()}-{Guid.NewGuid()}{media.Type}"; - // var newFilePath = Path.Combine(path, uniqueFileName); - // try - // { - // Directory.CreateDirectory(newFilePath); + // var uniqueFileName = $"{DocumentItemLabel.EmployeePicture.ToString()}-{Guid.NewGuid()}{media.Type}"; + // var newFilePath = Path.Combine(path, uniqueFileName); + // try + // { + // Directory.CreateDirectory(newFilePath); - // if (!System.IO.File.Exists(media.Path)) - // return op.Failed("فایل مورد نظر یافت نشد"); + // if (!System.IO.File.Exists(media.Path)) + // return op.Failed("فایل مورد نظر یافت نشد"); - // System.IO.File.Copy(media.Path, newFilePath); - // } - // catch - // { - // return op.Failed("در جابجایی فایل خطایی رخ داده است"); - // } + // System.IO.File.Copy(media.Path, newFilePath); + // } + // catch + // { + // return op.Failed("در جابجایی فایل خطایی رخ داده است"); + // } - // var mediaEntity = new Media(newFilePath, media.Type, "فایل", "EmployeeDocuments"); - // _mediaRepository.Create(mediaEntity); - // _mediaRepository.SaveChanges(); + // var mediaEntity = new Media(newFilePath, media.Type, "فایل", "EmployeeDocuments"); + // _mediaRepository.Create(mediaEntity); + // _mediaRepository.SaveChanges(); - // return op.Succcedded(mediaEntity.id); + // return op.Succcedded(mediaEntity.id); - //} + //} - /// - /// متد پر استفاده برای دریافت آخرین مدارک تایید شده فرد - /// - private static List GetCurrentConfirmedDocuments(EmployeeDocuments entity) - { - return entity.EmployeeDocumentItemCollection.Where(x => x.DocumentStatus == DocumentStatus.Confirmed) - .GroupBy(x => x.DocumentLabel) - .Select(x => x.MaxBy(y => y.CreationDate)).ToList(); - } + /// + /// متد پر استفاده برای دریافت آخرین مدارک تایید شده فرد + /// + private static List GetCurrentConfirmedDocuments(EmployeeDocuments entity) + { + return entity.EmployeeDocumentItemCollection.Where(x => x.DocumentStatus == DocumentStatus.Confirmed) + .GroupBy(x => x.DocumentLabel) + .Select(x => x.MaxBy(y => y.CreationDate)).ToList(); + } - /// - /// با توجه به جنسیت مدارک لازم را تعیین می کند، مثلا معافیت سربازی برای آقایان - /// - /// - /// "مرد" یا "زن" - private bool HasRequiredDocuments(List items, string gender) + /// + /// با توجه به جنسیت مدارک لازم را تعیین می کند، مثلا معافیت سربازی برای آقایان + /// + /// + /// "مرد" یا "زن" + private bool HasRequiredDocuments(List items, string gender) { @@ -1760,41 +1759,41 @@ namespace CompanyManagment.Application List labels = items.GroupBy(x => x.DocumentLabel) .Select(x => x.Key).ToList(); - //if labels has all the required labels - if (labels.Count(x => requiredDocuments.Contains(x)) == requiredDocuments.Count()) - return true; - return false; - } + //if labels has all the required labels + if (labels.Count(x => requiredDocuments.Contains(x)) == requiredDocuments.Count()) + return true; + return false; + } - //for mapping purposes - private static EmployeeDocumentItemViewModel GetItemFromCollectionByLabel(List items, - List medias, DocumentItemLabel label) - { - if (items == null || items.Count == 0) - return new(); - var item = items.FirstOrDefault(x => x.DocumentLabel == label); + //for mapping purposes + private static EmployeeDocumentItemViewModel GetItemFromCollectionByLabel(List items, + List medias, DocumentItemLabel label) + { + if (items == null || items.Count == 0) + return new(); + var item = items.FirstOrDefault(x => x.DocumentLabel == label); - if (item == null || item.MediaId == 0) - return new(); + if (item == null || item.MediaId == 0) + return new(); - return new EmployeeDocumentItemViewModel() - { - DocumentItemLabel = label, - Id = item.id, - Status = item.DocumentStatus, - StatusString = item.DocumentStatus.ToString().ToLower(), - PicturePath = medias.FirstOrDefault(x => x.Id == item.MediaId)?.Path ?? "", - RejectionMessage = item.RejectionReason, - UploaderType = item.UploaderType - }; - } + return new EmployeeDocumentItemViewModel() + { + DocumentItemLabel = label, + Id = item.id, + Status = item.DocumentStatus, + StatusString = item.DocumentStatus.ToString().ToLower(), + PicturePath = medias.FirstOrDefault(x => x.Id == item.MediaId)?.Path ?? "", + RejectionMessage = item.RejectionReason, + UploaderType = item.UploaderType + }; + } - private static string GetThumbnailPathFromFilePath(string filePath) - { - return string.IsNullOrWhiteSpace(filePath)? string.Empty: Path.Combine(Path.GetDirectoryName(filePath)!, Path.GetFileNameWithoutExtension(filePath) + $"-thumbnail{Path.GetExtension(filePath)}"); - } + private static string GetThumbnailPathFromFilePath(string filePath) + { + return string.IsNullOrWhiteSpace(filePath) ? string.Empty : Path.Combine(Path.GetDirectoryName(filePath)!, Path.GetFileNameWithoutExtension(filePath) + $"-thumbnail{Path.GetExtension(filePath)}"); + } #endregion #region Old MEthods @@ -1866,7 +1865,7 @@ namespace CompanyManagment.Application //} #endregion - + } } diff --git a/CompanyManagment.EFCore/Repository/EmployeeDocumentsRepository.cs b/CompanyManagment.EFCore/Repository/EmployeeDocumentsRepository.cs index 9192848c..07ddf786 100644 --- a/CompanyManagment.EFCore/Repository/EmployeeDocumentsRepository.cs +++ b/CompanyManagment.EFCore/Repository/EmployeeDocumentsRepository.cs @@ -594,12 +594,12 @@ public class EmployeeDocumentsRepository : RepositoryBase GetWorkshopsWithUploadedDocuments() { var itemsQuery = _companyContext.EmployeeDocumentItems - .Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted && x.DocumentStatus != DocumentStatus.SubmittedByClient) + .Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted) .Include(x => x.EmployeeDocuments) .ThenInclude(x => x.Workshop).ThenInclude(x=>x.WorkshopEmployers).ThenInclude(x=>x.Employer) .GroupBy(x=>x.WorkshopId).Select(x => new WorkshopWithEmployeeDocumentsViewModel() { - SubmittedItemsCount = x.Count(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin), + SubmittedItemsCount = x.Count(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin || y.DocumentStatus == DocumentStatus.SubmittedByClient), WorkshopId = x.Key, WorkshopFullName = x.First().EmployeeDocuments.Workshop.WorkshopName, EmployerName = x.First().EmployeeDocuments.Workshop.WorkshopEmployers.First().Employer.FullName @@ -666,7 +666,7 @@ public class EmployeeDocumentsRepository : RepositoryBase x.WorkshopId == workshopId) .Include(x => x.EmployeeDocumentItemCollection) .Where(x=>x.EmployeeDocumentItemCollection.Any(y => - y.DocumentStatus != DocumentStatus.Unsubmitted && y.DocumentStatus != DocumentStatus.SubmittedByClient)); + y.DocumentStatus != DocumentStatus.Unsubmitted)); var employeesList = _companyContext.Employees.Where(x => workshopDocuments.Any(y => y.EmployeeId == x.id)) @@ -688,8 +688,7 @@ public class EmployeeDocumentsRepository : RepositoryBase new { EmployeeDocuments = x, - EmployeeDocumentItemCollection = x.EmployeeDocumentItemCollection.Where(y=> y.DocumentStatus != DocumentStatus.Unsubmitted && - y.DocumentStatus != DocumentStatus.SubmittedByClient) + EmployeeDocumentItemCollection = x.EmployeeDocumentItemCollection.Where(y=> y.DocumentStatus != DocumentStatus.Unsubmitted) .GroupBy(y => y.DocumentLabel) .Select(y => y.MaxBy(z => z.CreationDate)) . ToList() @@ -709,8 +708,8 @@ public class EmployeeDocumentsRepository : RepositoryBase y.DocumentStatus != DocumentStatus.SubmittedByAdmin)).ToList(); else workshopDocumentsListWithConfirmed = workshopDocumentsListWithConfirmed.Where(x => - x.EmployeeDocumentItemCollection.Any(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin)).ToList(); - + x.EmployeeDocumentItemCollection.Any(y => y.DocumentStatus is DocumentStatus.SubmittedByAdmin or DocumentStatus.SubmittedByClient)).ToList(); + return workshopDocumentsListWithConfirmed.Select(x => new EmployeeDocumentsViewModel() { Id=x.EmployeeDocuments.id, @@ -737,7 +736,7 @@ public class EmployeeDocumentsRepository : RepositoryBasey.DocumentStatus==DocumentStatus.SubmittedByAdmin), + SubmittedItemsCount = x.EmployeeDocumentItemCollection.Count(y=>y.DocumentStatus is DocumentStatus.SubmittedByAdmin or DocumentStatus.SubmittedByClient), RejectedItemsCount = x.EmployeeDocumentItemCollection.Count(y => y.DocumentStatus == DocumentStatus.Rejected), ConfirmedItemsCount = x.EmployeeDocumentItemCollection.Count(y => y.DocumentStatus == DocumentStatus.Confirmed), EmployerFullName = employerName, @@ -753,7 +752,7 @@ public class EmployeeDocumentsRepository : RepositoryBase GetCheckerWorkFlowCount() { return await _companyContext.EmployeeDocumentItems.Include(x => x.EmployeeDocuments) - .CountAsync(x => x.DocumentStatus == DocumentStatus.SubmittedByAdmin); + .CountAsync(x => x.DocumentStatus == DocumentStatus.SubmittedByAdmin || x.DocumentStatus == DocumentStatus.SubmittedByClient); } @@ -833,7 +832,7 @@ public class EmployeeDocumentsRepository : RepositoryBase new MediaViewModel() { Id = x.id, Path = x.Path }).ToList(); workshopDocumentsListWithConfirmed = workshopDocumentsListWithConfirmed.Where(x => - x.EmployeeDocumentItemCollection.Any(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin)).ToList(); + x.EmployeeDocumentItemCollection.Any(y => y.DocumentStatus is DocumentStatus.SubmittedByAdmin or DocumentStatus.SubmittedByClient)).ToList(); return workshopDocumentsListWithConfirmed.Select(x => new EmployeeDocumentsViewModel() { diff --git a/ServiceHost/wwwroot/AssetsAdminNew/EmployeesDocumentsManagement/js/DetailsPersonnelModal.js b/ServiceHost/wwwroot/AssetsAdminNew/EmployeesDocumentsManagement/js/DetailsPersonnelModal.js index 04517f1a..961b8d64 100644 --- a/ServiceHost/wwwroot/AssetsAdminNew/EmployeesDocumentsManagement/js/DetailsPersonnelModal.js +++ b/ServiceHost/wwwroot/AssetsAdminNew/EmployeesDocumentsManagement/js/DetailsPersonnelModal.js @@ -71,7 +71,7 @@ $(document).ready(function () { $('.signHolder').each(function() { const buttonClass = $(this).find('button').attr('class'); const spanElement = $(this).find('span.sign'); - if (buttonClass.includes('submittedbyadmin')) { + if (buttonClass.includes('submittedbyadmin') || buttonClass.includes('submittedbyclient')) { $(this).addClass('pending'); spanElement.html(svgPending); } else if (buttonClass.includes('rejected')) { @@ -163,7 +163,7 @@ $(document).ready(function () { //debugger; let enable = false; $(".mg-btn.active").each(function () { - if ($(this).hasClass("submittedbyadmin")) { + if ($(this).hasClass("submittedbyadmin") || $(this).hasClass("submittedbyclient")) { enable = true; } }); @@ -301,7 +301,7 @@ function checkFields() { var inputValue = $("#label_" + index).val(); $("#confirm").click(function () { - $(this).removeClass('submittedbyadmin').addClass("confirmed"); + $(this).removeClass('submittedbyadmin submittedbyclient').addClass('confirmed'); $(this).closest('.signHolder').removeClass("pending").addClass("confirmed"); $(this).siblings("span.sign").html(svgConfirmed); //تایید توضیحات نمیخواد @@ -310,7 +310,7 @@ function checkFields() { }); $("#reject").click(function () { - $(this).removeClass('submittedbyadmin').addClass("reject"); + $(this).removeClass('submittedbyadmin submittedbyclient').addClass('reject'); $(this).closest('.signHolder').removeClass("pending").addClass("rejected"); $(this).siblings("span.sign").html(svgReject); inputValue = $("#message").val(); @@ -347,7 +347,7 @@ function rejectAjax() { showAlertMessage('.alert-success-msg', 'تصویر موجود رد شد.', 3500); - $(".mg-btn.active").removeClass('submittedbyadmin').addClass("reject"); + $(".mg-btn.active").removeClass('submittedbyadmin submittedbyclient').addClass('reject'); $(".mg-btn.active").closest('.signHolder').removeClass("pending").addClass("rejected"); $(".mg-btn.active").siblings("span.sign").html(svgReject); @@ -376,7 +376,7 @@ function confirmAjax() { showAlertMessage('.alert-success-msg', 'تصویر موجود تایید شد.', 3500); - $(".mg-btn.active").removeClass('submittedbyadmin').addClass("confirmed"); + $(".mg-btn.active").removeClass('submittedbyadmin submittedbyclient').addClass('confirmed'); $(".mg-btn.active").closest('.signHolder').removeClass("pending").addClass("confirmed"); $(".mg-btn.active").siblings("span.sign").html(svgConfirmed);