public CommittedProjects(ICommitted committedRepo, ISections sectionsRepo) { this.committedRepo = committedRepo; this.sectionsRepo = sectionsRepo; List <CommittedEntity> GetAnyProjects(int id, BridgeCareContext db, UserInformationModel userInformation) => committedRepo.GetCommittedProjects(id, db); List <CommittedEntity> GetPermittedProjects(int id, BridgeCareContext db, UserInformationModel userInformation) => committedRepo.GetPermittedCommittedProjects(id, db, userInformation.Name); void SaveAnyProjects(List <CommittedProjectModel> models, BridgeCareContext db, UserInformationModel userInformation) => committedRepo.SaveCommittedProjects(models, db); void SavePermittedProjects(List <CommittedProjectModel> models, BridgeCareContext db, UserInformationModel userInformation) => committedRepo.SavePermittedCommittedProjects(models, db, userInformation.Name); CommittedProjectsGetMethods = new Dictionary <string, CommittedProjectsGetMethod> { [Role.ADMINISTRATOR] = GetAnyProjects, [Role.DISTRICT_ENGINEER] = GetPermittedProjects, [Role.CWOPA] = GetPermittedProjects, [Role.PLANNING_PARTNER] = GetPermittedProjects }; CommittedProjectsSaveMethods = new Dictionary <string, CommittedProjectsSaveMethod> { [Role.ADMINISTRATOR] = SaveAnyProjects, [Role.DISTRICT_ENGINEER] = SavePermittedProjects, [Role.CWOPA] = SavePermittedProjects, [Role.PLANNING_PARTNER] = SavePermittedProjects }; }
/// <summary> /// Export committed projects for a simulation /// </summary> /// <param name="simulationId"></param> /// <param name="networkId"></param> /// <param name="db"></param> /// <returns></returns> public byte[] ExportCommittedProjects(int simulationId, int networkId, BridgeCareContext db) { using (ExcelPackage excelPackage = new ExcelPackage(new System.IO.FileInfo("CommittedProjects.xlsx"))) { // This method may stay here or if too long then move to helper class Fill(worksheet, , db); var committedProjects = committedRepo.GetCommittedProjects(simulationId, db); var worksheet = excelPackage.Workbook.Worksheets.Add("Committed Projects"); if (committedProjects.Count != 0) { AddHeaderCells(worksheet, committedProjects.FirstOrDefault().COMMIT_CONSEQUENCES.ToList()); AddDataCells(worksheet, committedProjects, networkId, db); } return(excelPackage.GetAsByteArray()); } }