Exemplo n.º 1
0
 public Vehicle(string manufacturer, string model, int? year, int? horsePower, int? mileage,
     FuelType fuelType, Gearbox gearbox, Person owner,
     string color, string comments, string registrationNumber, List<Repair> repairs, Status status = Status.New)
     : base(manufacturer, model, year, fuelType, gearbox)
 {
     this.HorsePower = horsePower;
     this.Mileage = mileage;
     this.Owner = owner;
     this.Color = color;
     this.Comments = comments;
     this.RegistrationNumber = registrationNumber;
     this.Repairs = repairs;
     this.Status = status;
 }
Exemplo n.º 2
0
        public static string SaveOwnerInformation(Person owner)
        {
            StringBuilder builder = new StringBuilder();

            var assembly = Assembly.GetExecutingAssembly();

            var ownerProperties = assembly.GetType("GarageManagementSystem.Owner").GetProperties();

            foreach (var property in ownerProperties)
            {
                if (property.Name == "Address")
                {
                    builder.AppendLine("Address");
                    if (owner.Address == null)
                    {
                        builder.AppendLine("-");
                    }
                    else
                    {
                        builder.AppendLine("1");
                        builder.Append(Address.SaveAddressInformation(owner.Address));
                    }
                }
                else
                {
                    builder.AppendLine(property.Name);
                    try
                    {
                        builder.AppendLine(property.GetValue(owner, null).ToString());
                    }
                    catch (NullReferenceException)
                    {
                        builder.AppendLine("-");
                    }
                }
            }

            return builder.ToString();
        }