예제 #1
0
        public CarForm FindCarDetails(string model, string langCode)
        {
            var collection = _database.GetCollection <Car>(Constants.Db.CollectionNameCar);

            try
            {
                var result = collection.AsQueryable().First(o => o.Model.Equals(model));

                var specLangDesc = _finder.Find(result.Descriptions, langCode);

                var specifiedCar = new CarForm
                {
                    Brand           = result.Brand,
                    Model           = result.Model,
                    Seats           = result.NumberOfSeats,
                    MaxSpeed        = result.MaxSpeed,
                    DescriptionLang = specLangDesc.Language,
                    Description     = specLangDesc.Content
                };
                return(specifiedCar);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                throw;
            }
        }
예제 #2
0
        public LanguageElement FindByLanguage(ICollection <LanguageElement> collection, string langCode)
        {
            var descriptions = collection.FirstOrDefault(desc => desc.Language.Equals(langCode));
            var message      = descriptions ?? NextSelector.Find(collection, langCode);

            return(message);
        }