Exemplo n.º 1
0
        private HopStepDto GetHopStepDto(Hop hop)
        {
            var hopForms = _hopRepository.GetHopForms();
            var hopDto   = _hopElasticsearch.Search(hop.Name, 0, 1).FirstOrDefault();

            if (hopDto == null)
            {
                {
                    Log.ErrorFormat("MISSING HOP: {0}", hop.Name);
                    return(null);
                };
            }
            ;
            var hopStepDto = Mapper.Map <HopDto, HopStepDto>(hopDto);

            hopStepDto.HopId = hopDto.Id;
            double alpha = double.Parse(hop.Alpha, CultureInfo.InvariantCulture);

            hopStepDto.AAValue = alpha;
            double amount = double.Parse(hop.Amount, CultureInfo.InvariantCulture);

            hopStepDto.Amount  = (int)Math.Round(amount * 1000, 0);
            hopStepDto.HopForm =
                Mapper.Map <HopForm, DTO>(hopForms.FirstOrDefault(
                                              h => string.Equals(h.Name, hop.Form, StringComparison.OrdinalIgnoreCase)));
            return(hopStepDto);
        }
        private HopStepDto GetHopStepDto(Model.BeerXml.Hop hop)
        {
            var hopForms = _hopRepository.GetHopFormsAsync().Result;
            var hopDto   = _hopElasticsearch.Search(hop.Name, 0, 1).FirstOrDefault();

            if (hopDto == null)
            {
                {
                    return(null);
                };
            }
            ;
            var hopStepDto = AutoMapper.Mapper.Map <HopDto, HopStepDto>(hopDto);

            hopStepDto.HopId = hopDto.Id;
            double alpha = double.Parse(hop.Alpha, CultureInfo.InvariantCulture);

            hopStepDto.AAValue = alpha;
            double amount = double.Parse(hop.Amount, CultureInfo.InvariantCulture);

            hopStepDto.Amount = (int)Math.Round(amount * 1000, 0);
            var hopForm =
                hopForms.FirstOrDefault(h => string.Equals(h.Name, hop.Form, StringComparison.OrdinalIgnoreCase)) ??
                hopForms.First();

            hopStepDto.SubType = hopForm.Name;
            return(hopStepDto);
        }