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; } }
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); }