public ProjectExportService(IUnitOfWork unitOfWork, IWebHostEnvironment environment, ILogger <ProjectExportService> logger) { _unitOfWork = unitOfWork; _environment = environment; _logger = logger; _csvWriter = null; _projectId = 0; _project = null; _projectJurisdiction = null; _schemeTree = null; _codedTextExport = false; _schemeCategories = null; _codedCategories = null; _schemeCategory = null; _outlineNumber = ""; _processingCategoryQuestions = false; _userId = -1; _codedUser = null; _validated = true; }
private async Task <int> WriteJurisdictionAnswers() { var error = ExportResult.NoError; var projectJurisdictions = await _unitOfWork.ProjectJurisdictions.FindAsync(pj => pj.Project.Id == _projectId); foreach (var projectJurisdiction in projectJurisdictions) { // set ProjectJurisdiction for other methods _projectJurisdiction = projectJurisdiction; _csvWriter.WriteField(projectJurisdiction.Jurisdiction.Name); _csvWriter.WriteField(projectJurisdiction.Jurisdiction.FipsCode); _csvWriter.WriteField(projectJurisdiction.Jurisdiction.GnisCode); _csvWriter.WriteField(projectJurisdiction.StartDate.Date.ToShortDateString()); _csvWriter.WriteField(projectJurisdiction.EndDate.Date.ToShortDateString()); error = await WriteQuestionAnswers(_schemeTree); await _csvWriter.NextRecordAsync(); } return(error); }