Example #1
0
        private bool TryAddMalfunction(Vehicle vehicle, MalfunctionType malfunctionType)
        {
            if (vehicle.Status == VehicleStatus.Pending || vehicle.Status == VehicleStatus.WaitingForRepair || vehicle.Status == VehicleStatus.Broken)
            {
                return(false);
            }

            vehicle.Malfunctions
            .Add(new Malfunction()
            {
                VehicleId    = vehicle.Id,
                Type         = malfunctionType,
                CreatedOnUtc = DateTime.Now
            });

            vehicle.Status = malfunctionType == MalfunctionType.Light ? VehicleStatus.WaitingForRepair : VehicleStatus.Broken;

            return(true);
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Malfunction"/> class.
 /// </summary>
 /// <param name="vehicle">The vehicle.</param>
 /// <param name="malfunctionType">The malfunction type.</param>
 internal Malfunction(Vehicle vehicle, MalfunctionType malfunctionType)
 {
     VehicleId = vehicle.Id;
     Type      = malfunctionType;
 }