public void SaveSnapshot(NominationList nominationList) { if (nominationList == null) { throw new ArgumentNullException(nameof(nominationList)); } if (!nominationList.IsDirty) { return; } var directoryPath = GetDirectoryPath(); Directory.CreateDirectory(directoryPath); var filePath = Path.Combine(directoryPath, DateTime.Now.Ticks + ".json"); using (var file = File.CreateText(filePath)) { var serializer = new JsonSerializer(); serializer.Serialize(file, new NominationListDto(nominationList)); } nominationList.SetCurrent(); }
public NominationList LoadSurveyExport(AwardCategory awardCategory, FilePath filePath) { var excel = new ExcelQueryFactory(filePath.Value) { ReadOnly = true }; IEnumerable <Nomination> nominations; if (awardCategory == AwardCategory.QuarterlyAwards) { nominations = LoadQuarterlyAwardsSurveyExport(excel); } else if (awardCategory == AwardCategory.SuperStarAwards) { nominations = LoadSuperStarAwardsSurveyExport(excel); } else { throw new NotSupportedException($@"Unsupported award category: {awardCategory.Value}"); } var nominationList = new NominationList(_workingDirectoryPath.AwardsPeriod, nominations); SaveSnapshot(nominationList); return(nominationList); }