public async Task <MABusinessModel> GetMAAsync(int id) { var entity = await _maService.GetMA(id); return(entity); }
public async Task <Domain.Document.Document> GenerateRegistrationPDFDocument(INodeServices nodeServices, int maId, string statusCode, int userId, string Comment = null) { var letterHeading = await _letterHeadingService.GetAsync(1); var ma = await _maService.GetMA(maId); //check if agent-supplier relationship changes //TODO agent-supplier change var agentSupplier = await _agentSupplierService.GetAsync(ags => ags.SupplierID == ma.MA.SupplierID && ags.AgentLevel.AgentLevelCode == "F*G" && ags.IsActive); if (agentSupplier.AgentID != ma.MA.AgentID) { ma.MA.AgentID = agentSupplier.AgentID; ma.MA.Agent = agentSupplier.Agent; } string htmlFilePath = constructHtmlPath(ma.Product.ProductType.SubmoduleType.SubmoduleTypeCode); Letter letter = new Letter(); ModuleDocument moduleDocument = new ModuleDocument(); string moduleCode = null; RegistrationPDFData data = null; switch (statusCode) { case "RQST": letter = (await _letterService.GetAsync(x => x.ModuleDocument.DocumentType.DocumentTypeCode == "MACKL" && x.ModuleDocument.Submodule.SubmoduleCode == ma.MA.MAType.MATypeCode)); moduleDocument = await _moduleDocumentService.GetAsync(letter.ModuleDocumentID); data = new RegistrationPDFData(ma, letterHeading, letter); var requestedStatus = await _maStatusService.GetMALogStatus(ma.MA.ID, "RQST"); data.applicationDate = requestedStatus?.CreatedDate.ToString("dd-MM-yyyy"); htmlFilePath = $"{htmlFilePath}acknowledgement.html"; break; case "FIR": letter = (await _letterService.GetAsync(x => x.ModuleDocument.DocumentType.DocumentTypeCode == "MAFIR" && x.ModuleDocument.Submodule.SubmoduleCode == ma.MA.MAType.MATypeCode)); moduleDocument = await _moduleDocumentService.GetAsync(letter.ModuleDocumentID); var review = await _maService.GetMAReview(ma.MA.ID, "TLD", "FIR"); var noOfFIR = (await _maStatusService.GetMALogStatuses(ma.MA.ID, "FIR")).Count(); data = new RegistrationPDFData(ma, letterHeading, letter, noOfFIR); data.review = review?.Comment; data.firGeneratedDate = review?.CreatedDate.ToString("dd-MM-yyyy"); data.firDueDate = review?.FIRDueDate?.ToString("dd-MM-yyyy"); htmlFilePath = $"{htmlFilePath}firRequest.html"; break; case "RTA": letter = (await _letterService.GetAsync(x => x.ModuleDocument.DocumentType.DocumentTypeCode == "MADFL" && x.ModuleDocument.Submodule.SubmoduleCode == ma.MA.MAType.MATypeCode)); moduleDocument = await _moduleDocumentService.GetAsync(letter.ModuleDocumentID); data = new RegistrationPDFData(ma, letterHeading, letter); data.deficiency = (await _checklistService.GetPrescreeningDeficiency(ma.MA.ID)).ToList().Select(d => new Checklist(d)).ToList(); htmlFilePath = $"{htmlFilePath}deficiency.html"; break; case "APR": letter = (await _letterService.GetAsync(x => x.ModuleDocument.DocumentType.DocumentTypeCode == "MACRT" && x.ModuleDocument.Submodule.SubmoduleCode == ma.MA.MAType.MATypeCode)); moduleDocument = await _moduleDocumentService.GetAsync(letter.ModuleDocumentID); var approvedStatus = await _maStatusService.GetMALogStatus(ma.MA.ID, "APR"); data = new RegistrationPDFData(ma, letterHeading, letter); data.approvalDate = approvedStatus?.CreatedDate.ToString("dd-MM-yyyy"); data.certificateValidDate = ((DateTime)ma.MA.ExpiryDate).ToString("dd-MM-yyyy"); htmlFilePath = $"{htmlFilePath}registration.html"; break; case "NOTAPR": letter = (await _letterService.GetAsync(x => x.ModuleDocument.DocumentType.DocumentTypeCode == "VANL" && x.ModuleDocument.Submodule.SubmoduleCode == ma.MA.MAType.MATypeCode)); moduleDocument = await _moduleDocumentService.GetAsync(letter.ModuleDocumentID); approvedStatus = await _maStatusService.GetMALogStatus(ma.MA.ID, "APR"); data = new RegistrationPDFData(ma, letterHeading, letter); data.approvalDate = approvedStatus?.CreatedDate.ToString("dd-MM-yyyy"); data.certificateValidDate = approvedStatus?.CreatedDate.ToString("dd-MM-yyyy"); data.variationChanges = ((await _maService.GetVariationChangesAsync(ma.MA.ID))?.Select(v => new VariationDifference(v))).ToList(); data.review = Comment; htmlFilePath = $"{htmlFilePath}notificationApprove.html"; break; case "REJ": letter = (await _letterService.GetAsync(x => x.ModuleDocument.DocumentType.DocumentTypeCode == "MAREJ" && x.ModuleDocument.Submodule.SubmoduleCode == ma.MA.MAType.MATypeCode)); moduleDocument = await _moduleDocumentService.GetAsync(letter.ModuleDocumentID); review = await _maService.GetMAReview(ma.MA.ID, "TLD", "SFR"); data = new RegistrationPDFData(ma, letterHeading, letter); data.review = review?.Comment; htmlFilePath = $"{htmlFilePath}rejection.html"; break; case "LABR": letter = (await _letterService.GetAsync(x => x.ModuleDocument.DocumentType.DocumentTypeCode == "PMNL" && x.ModuleDocument.Submodule.SubmoduleCode == ma.MA.MAType.MATypeCode)); moduleDocument = await _moduleDocumentService.GetAsync(letter.ModuleDocumentID); data = new RegistrationPDFData(ma, letterHeading, letter); data.applicationType = moduleDocument.Submodule.Module.Name; htmlFilePath = $"{htmlFilePath}sampleRequest.html"; break; case "CONL": letter = (await _letterService.GetAsync(x => x.ModuleDocument.DocumentType.DocumentTypeCode == "CONL" && x.ModuleDocument.Submodule.SubmoduleCode == ma.MA.MAType.MATypeCode)); moduleDocument = await _moduleDocumentService.GetAsync(letter.ModuleDocumentID); data = new RegistrationPDFData(ma, letterHeading, letter); data.applicationType = moduleDocument.Submodule.Module.Name; htmlFilePath = $"{htmlFilePath}notificationRequest.html"; break; case "FNT": letter = (await _letterService.GetAsync(x => x.ModuleDocument.DocumentType.DocumentTypeCode == "FNT" && x.ModuleDocument.Submodule.SubmoduleCode == ma.MA.MAType.MATypeCode)); moduleDocument = await _moduleDocumentService.GetAsync(letter.ModuleDocumentID); data = new RegistrationPDFData(ma, letterHeading, letter); data.applicationType = moduleDocument.Submodule.Module.Name; approvedStatus = await _maStatusService.GetMALogStatus(ma.MA.ID, "APR"); data.approvalDate = approvedStatus?.CreatedDate.ToString("dd-MM-yyyy"); data.certificateValidDate = ((DateTime)ma.MA.ExpiryDate).ToString("dd-MM-yyyy"); htmlFilePath = $"{htmlFilePath}foodNotificationType.html"; break; case "MDNT": letter = (await _letterService.GetAsync(x => x.ModuleDocument.DocumentType.DocumentTypeCode == "MDNT" && x.ModuleDocument.Submodule.SubmoduleCode == ma.MA.MAType.MATypeCode)); moduleDocument = await _moduleDocumentService.GetAsync(letter.ModuleDocumentID); data = new RegistrationPDFData(ma, letterHeading, letter); data.applicationType = moduleDocument.Submodule.Module.Name; approvedStatus = await _maStatusService.GetMALogStatus(ma.MA.ID, "APR"); data.approvalDate = approvedStatus?.CreatedDate.ToString("dd-MM-yyyy"); data.certificateValidDate = ((DateTime)ma.MA.ExpiryDate).ToString("dd-MM-yyyy"); htmlFilePath = $"{htmlFilePath}mdNotificationType.html"; break; default: break; } moduleCode = moduleDocument?.Submodule?.Module?.ModuleCode; return(moduleCode == null? null : await Generate(nodeServices, data, letter, htmlFilePath, moduleCode, userId)); }