public void LoadWhiskies() { var whiskyFileContent = File.ReadAllLines(WhiskiesFilePath); foreach (var whiskyLine in whiskyFileContent) { var whiskyData = whiskyLine.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries); if (whiskyData.Length == 3) { var distilleryName = whiskyData[0]; var whiskyName = whiskyData[1]; var alcoholPercentage = Convert.ToSingle(whiskyData[2]); var distillery = distilleryRepository.Find(distilleryName); if (distillery != null) { var whisky = new Whisky { Id = Guid.NewGuid(), Name = whiskyName, AlcoholPercentage = alcoholPercentage, DistilleryId = distillery.Id }; whiskyRepository.Store(whisky); } } } }
public object Get(Whiskies whiskies) { if (whiskies.DistilleryId != Guid.Empty) { var distillery = distilleryRepository.Find(whiskies.DistilleryId); var distilleryWhiskies = whiskyRepository.FindByDistillery(distillery); return(distilleryWhiskies); } if (!string.IsNullOrWhiteSpace(whiskies.SearchFilter)) { return(whiskyRepository.Find(whiskies.SearchFilter)); } return(whiskyRepository.GetAll()); }