protected override IList <HopStepDto> ResolveCore(FermentationStep step) { var hopStepDtoList = new List <HopStepDto>(); foreach (var item in step.Hops) { var hopStepDto = new HopStepDto() { HopId = item.HopId, StepNumber = item.StepNumber, Amount = item.Amount, AAValue = item.AAValue, RecipeId = item.RecipeId, }; var hop = _hopElasticsearch.GetSingle(item.HopId); if (hop == null) { hop = Mapper.Map <Hop, HopDto>(_hopRepository.GetSingle(item.HopId)); } hopStepDto.Name = hop.Name; hopStepDto.Origin = hop.Origin; //hopStepDto.Flavours = hop.Flavours; //hopStepDto.FlavourDescription = hop.FlavourDescription; hopStepDto.HopForm = Mapper.Map <HopForm, DTO>(_hopRepository.GetForm(item.HopFormId)); hopStepDtoList.Add(hopStepDto); } return(hopStepDtoList); }
// private readonly IYeastElasticsearch _elasticsearch = new YeastElasticsearch(); // private readonly IYeastRepository _yeastRepository = new YeastDapperRepository(); protected override IList <YeastStepDto> ResolveCore(FermentationStep step) { var yeastStepDtoList = new List <YeastStepDto>(); // foreach (var item in step.Yeasts) // { // var yeastStepDto = new YeastStepDto() // { // YeastId = item.YeastId, // Amount = item.Amount, // RecipeId = item.RecipeId, // Number = item.StepNumber, // // }; // var yeast = _elasticsearch.GetSingle(item.YeastId); // if (yeast == null) // { // yeast = Mapper.Map<Yeast, YeastDto>(_yeastRepository.GetSingle(item.YeastId)); // } // yeastStepDto.Name = yeast.Name; // yeastStepDto.Supplier = yeast.Supplier; // yeastStepDto.SubType = yeast.Type; // yeastStepDto.ProductCode = yeast.ProductCode; // // yeastStepDtoList.Add(yeastStepDto); // // } return(yeastStepDtoList); }
protected override IList <YeastStepDto> ResolveCore(FermentationStep step) { var yeastStepDtoList = new List <YeastStepDto>(); foreach (var item in step.Yeasts) { var yeastStepDto = new YeastStepDto() { YeastId = item.YeastId, Amount = item.Amount, RecipeId = item.RecipeId, Number = item.StepNumber, }; var yeast = _elasticsearch.GetSingle(item.YeastId); if (yeast == null) { yeast = Mapper.Map <Yeast, YeastDto>(_yeastRepository.GetSingle(item.YeastId)); } yeastStepDto.Name = yeast.Name; yeastStepDto.Supplier = yeast.Supplier; yeastStepDto.Type = yeast.Type; yeastStepDto.ProductCode = yeast.ProductCode; yeastStepDtoList.Add(yeastStepDto); } return(yeastStepDtoList); }
protected override IList <OtherStepDto> ResolveCore(FermentationStep step) { var otherStepDtoList = new List <OtherStepDto>(); foreach (var item in step.Others) { var otherStepDto = new OtherStepDto() { OtherId = item.OtherId, Amount = item.Amount, RecipeId = item.RecipeId, Number = item.StepNumber, }; var other = _otherElasticsearch.GetSingle(item.OtherId); if (other == null) { other = Mapper.Map <Other, OtherDto>(_otherRepository.GetSingle(item.OtherId)); } otherStepDto.Name = other.Name; otherStepDto.Type = other.Type; otherStepDtoList.Add(otherStepDto); } return(otherStepDtoList); }
//private readonly IFermentableElasticsearch _fermentableElasticsearch = new FermentableElasticsearch(); //private readonly IFermentableRepository _fermentableRepository = new FermentableDapperRepository(); protected override IList <FermentableStepDto> ResolveCore(FermentationStep step) { var fermentableStepDtoList = new List <FermentableStepDto>(); // foreach (var item in step.Fermentables) // { // var fermentable = _fermentableElasticsearch.GetSingle(item.FermentableId); // if (fermentable == null) // { // fermentable = Mapper.Map<Fermentable, FermentableDto>(_fermentableRepository.GetSingle(item.FermentableId)); // } // var fermentableStepDto = new FermentableStepDto(); // // fermentableStepDto.FermentableId = item.FermentableId; // fermentableStepDto.Amount = item.Amount; // fermentableStepDto.Supplier = fermentable.Supplier; // fermentableStepDto.SubType = fermentable.Type; // fermentableStepDto.Name = fermentable.Name; // fermentableStepDto.PPG = fermentable.PPG; // // if(item.Lovibond == 0) // { // fermentableStepDto.Lovibond = item.Lovibond; // } // else // { // fermentableStepDto.Lovibond = fermentable.Lovibond; // } // fermentableStepDtoList.Add(fermentableStepDto); // } return(fermentableStepDtoList); }
protected override IList <IIngredientStepDto> ResolveCore(FermentationStep source) { var ingredients = new List <IIngredientStepDto>(); // var hops = Mapper.Map<ICollection<FermentationStepHop>, IList<HopStepDto>>(source.Hops); // ingredients.AddRange(hops); // var fermentables = Mapper.Map<ICollection<FermentationStepFermentable>, IList<FermentableStepDto>>(source.Fermentables); // ingredients.AddRange(fermentables); // var others = Mapper.Map<ICollection<FermentationStepOther>, IList<OtherStepDto>>(source.Others); // ingredients.AddRange(others); return(ingredients); }
protected override IList <FermentableStepDto> ResolveCore(FermentationStep step) { var fermentableStepDtoList = new List <FermentableStepDto>(); foreach (var item in step.Fermentables) { var fermentable = _fermentableElasticsearch.GetSingle(item.FermentableId); if (fermentable == null) { fermentable = Mapper.Map <Fermentable, FermentableDto>(_fermentableRepository.GetSingle(item.FermentableId)); } var fermentableStepDto = new FermentableStepDto(); fermentableStepDto.FermentableId = item.FermentableId; fermentableStepDto.StepNumber = item.StepNumber; fermentableStepDto.Amount = item.Amount; fermentableStepDto.Supplier = fermentable.Supplier; fermentableStepDto.Type = fermentable.Type; fermentableStepDto.Name = fermentable.Name; fermentableStepDto.PPG = fermentable.PPG; fermentableStepDto.RecipeId = item.RecipeId; fermentableStepDto.StepNumber = item.StepNumber; if (item.Lovibond == 0) { fermentableStepDto.Lovibond = item.Lovibond; } else { fermentableStepDto.Lovibond = fermentable.Lovibond; } fermentableStepDtoList.Add(fermentableStepDto); } return(fermentableStepDtoList); }
// private readonly IOtherElasticsearch _otherElasticsearch = new OtherElasticsearch(); // private readonly IOtherRepository _otherRepository = new OtherDapperRepository(); protected override IList <OtherStepDto> ResolveCore(FermentationStep step) { var otherStepDtoList = new List <OtherStepDto>(); // foreach (var item in step.Others) // { // // var otherStepDto = new OtherStepDto() // { // OtherId = item.OtherId, // Amount = item.Amount, // }; // var other = _otherElasticsearch.GetSingle(item.OtherId); // if (other == null) // { // other = Mapper.Map<Other, OtherDto>(_otherRepository.GetSingle(item.OtherId)); // } // otherStepDto.Name = other.Name; // otherStepDto.SubType = other.Type; // otherStepDtoList.Add(otherStepDto); // // } return(otherStepDtoList); }