Ejemplo n.º 1
0
        public static List <VehicleName> BuildNames(this Persistence.Vehicle vehicle)
        {
            List <VehicleName> vehicles = new List <VehicleName>();

            foreach (var seriesRunner in vehicle.SeriesVehicles.Select(x => x.Series))
            {
                var name          = $"{seriesRunner.Manufacturer.Name} {seriesRunner.Name} {vehicle.Name}";
                var teaserPicture = vehicle.VehiclePictures
                                    .OrderBy(runner => runner.SortOrder)
                                    .FirstOrDefault();
                vehicles.Add(new VehicleName()
                {
                    VehicleGuid = vehicle.Guid, Name = name, PictureGuid = teaserPicture?.PictureGuid
                });
            }

            foreach (var manufacturerRunner in vehicle.ManufacturerVehicles.Select(x => x.Manufacturer))
            {
                var name          = $"{manufacturerRunner.Name} {vehicle.Name}";
                var teaserPicture = vehicle.VehiclePictures
                                    .OrderBy(runner => runner.SortOrder)
                                    .FirstOrDefault();
                vehicles.Add(new VehicleName()
                {
                    VehicleGuid = vehicle.Guid, Name = name, PictureGuid = teaserPicture?.PictureGuid
                });
            }

            return(vehicles);
        }
Ejemplo n.º 2
0
                //Constructors
                #region SeriesVehicleViewModel
                public SeriesVehicleViewModel(Persistence.Vehicle vehicle)
                {
                    this.Guid = vehicle.Guid;
                    this.Name = vehicle.Name;

                    var teaser = vehicle.VehiclePictures.OrderBy(runner => runner.SortOrder).FirstOrDefault();

                    this.PictureGuid = teaser?.PictureGuid;
                }
            //Constructor
            #region Preview
            public Preview(Persistence.Vehicle vehicle)
            {
                this.Guid  = vehicle.Guid;
                this.Title = vehicle.BuildNames().FirstOrDefault()?.Name;
                this.Date  = vehicle.CreateTimeStamp;

                var teaser = vehicle.VehiclePictures.OrderBy(runner => runner.SortOrder).FirstOrDefault();

                if (teaser != null)
                {
                    this.TextTeaser      = String.Concat(teaser.Text.Take(300).ToList()) + "...";
                    this.TeaserImageGuid = teaser.PictureGuid;
                }
            }
Ejemplo n.º 4
0
            //Constructor
            #region Details
            /// <summary>
            /// Initializes a new instance of the <see cref="Details"/> class.
            /// </summary>
            /// <param name="vehicle">The news.</param>
            public Details(Persistence.Vehicle vehicle)
            {
                this.Guid          = vehicle.Guid;
                this.Title         = vehicle.BuildNames().FirstOrDefault()?.Name;
                this.Date          = vehicle.CreateTimeStamp;
                this.Manufacturers = vehicle.ManufacturerVehicles
                                     .Select(runner => runner.Manufacturer)
                                     .Union(vehicle.SeriesVehicles.Select(x => x.Series.Manufacturer))
                                     .Distinct()
                                     .Select(runner => new ManufacturerViewModel(runner));

                this.Series = vehicle.SeriesVehicles
                              .Select(runner => new SeriesViewModel(runner.Series));

                this.Garages = vehicle.Garages
                               .OrderByDescending(runner => runner.CreateTimeStamp)
                               .Select(runner => new GarageViewModel(runner));

                this.TechnicalData.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.Code, Value = vehicle.Name
                });
                this.TechnicalData.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.VehicleType, Value = vehicle.VehicleTypeString
                });
                this.TechnicalData.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.BuiltFrom, Value = vehicle.BuiltFromYear.ToString()
                });
                this.TechnicalData.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.BuiltUntil, Value = vehicle.BuiltUntilYear.HasValue ? vehicle.BuiltUntilYear.Value.ToString() : StringTable.UntilToday
                });
                this.TechnicalData.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.SpeedMax, Value = vehicle.SpeedMaxKMH
                });
                this.TechnicalData.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.CylinderCount, Value = vehicle.CylinderCount
                });
                this.TechnicalData.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.CylinderCapacity, Value = vehicle.CylinderCapacityCCM
                });
                this.TechnicalData.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.EngineOutput, Value = vehicle.EngineOutputPS
                });
                this.TechnicalData.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.EngineRpm, Value = vehicle.EngineRPM
                });
                this.TechnicalData.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.Length, Value = vehicle.LengthCM
                });
                this.TechnicalData.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.Width, Value = vehicle.WidthCM
                });
                this.TechnicalData.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.Height, Value = vehicle.HeightCM
                });
                this.TechnicalData = this.TechnicalData
                                     .Where(runner => !String.IsNullOrWhiteSpace(runner.Value))
                                     .ToList();

                this.ArticleParts.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.Intro, Value = vehicle.Intro.ToHtml()
                });
                this.ArticleParts.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.Technic, Value = vehicle.Technic.ToHtml()
                });
                this.ArticleParts.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.History, Value = vehicle.GetHistory().ToHtml()
                });
                this.ArticleParts.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.PressComment, Value = vehicle.PressComment.ToHtml()
                });
                this.ArticleParts.Add(new ArticalPartViewModel()
                {
                    Key = StringTable.Today, Value = vehicle.Today.ToHtml()
                });
                this.ArticleParts = this.ArticleParts
                                    .Where(runner => !String.IsNullOrWhiteSpace(runner.Value))
                                    .ToList();

                this.PicturesGuids = vehicle.VehiclePictures
                                     .OrderBy(runner => runner.SortOrder)
                                     .Select(runner => runner.PictureGuid);
                this.WikipediaLink = vehicle.WikipediaLink;
            }