public void TestNullAcceptance() { //Arrange DateTime now = DateTime.Now; TimeSpan time = new TimeSpan(2, 3, 4); TrainingType training = TrainingType.Endurance; BikeType bike = BikeType.CityBike; //Act CyclingSession cyclingSession = new CyclingSession(now, null, time, null, null, training, null, bike); //Assert Assert.IsNull(cyclingSession.AverageSpeed, "AverageSpeed did not accept null"); Assert.IsNull(cyclingSession.Distance, "Distance did not accept null"); Assert.IsNull(cyclingSession.AverageWatt, "Wattage did not accept null"); Assert.IsNull(cyclingSession.Comments, "comments did not accept null"); Assert.IsNotNull(cyclingSession.When, "When was also made null"); Assert.IsNotNull(cyclingSession.Time, "Time was also made null"); Assert.IsNotNull(cyclingSession.TrainingType, "TrainingType was also made null"); Assert.IsNotNull(cyclingSession.BikeType, "BikeType was also made null"); }
public string OVBikeType(BikeType a) { //convert to string switch (a) { case BikeType.CityBike: return("City bike"); case BikeType.IndoorBike: return("Indoor bike"); case BikeType.MountainBike: return("Mountain bike"); case BikeType.RacingBike: return("Racing bike"); default: return("Unknown bike"); } }
private void bSave_Click(object sender, RoutedEventArgs e) { DateTime date = GetDate(); float? distance = GetDistance(); TimeSpan time = GetTime(); int? averageWatt = GetWatt(); TrainingType trainType = GetTrainingType(); float? averageSpeed = GetAverageSpeed(); string comments = GetComment(); BikeType bikeType = GetBikeType(); try { training.AddCyclingTraining(date, distance, time, averageSpeed, averageWatt, trainType, comments, bikeType); MessageBox.Show("Training werd toegevoegd"); } catch (Exception ex) { MessageBox.Show("Niet gelukt om training toe te voegen"); } }
public static void MakeBike(string num, BikeType typ) { //var bikes = new List<Bike> { // new Bike {Number = "001", BikeType = BikeType.Montain}, // new Bike {Number = "002", BikeType = BikeType.Montain} //}; //var bike = new Bike(); //bike.Number = num; //bike.BikeType = typ; //AddRange - wieksza kolekcja var bike = new Bike { Number = num, BikeType = typ }; using (var context = new DBConnection()) { context.Bikes.Add(bike); context.SaveChanges(); } }
private void LoadManufactures() { Manufactures = new ObservableCollection <BikeManufacture>(); var bikeTypes = new BikeType() { DesignType = "Electric" }; var listBikeTypes = new ObservableCollection <BikeType>(); listBikeTypes.Add(bikeTypes); Manufactures.Add(new BikeManufacture() { BikeName = "A-Bike", Country = "EUROPE", BikeModels = listBikeTypes }); Manufactures[0].BikeModels.Add(new BikeType() { DesignType = "Set2" }); Manufactures.Add(new BikeManufacture() { BikeName = "Argon", Country = "USA" }); }
private BikeType GetBikeType() { BikeType trainingType = BikeType.CityBike; switch (bikeTypeInput.SelectedItem.ToString()) { case "Indoor Bike": trainingType = BikeType.IndoorBike; break; case "Racing Bike": trainingType = BikeType.RacingBike; break; case "City Bike": trainingType = BikeType.CityBike; break; case "Mountain Bike": trainingType = BikeType.MountainBike; break; } return((BikeType)trainingType); }
public static BikeStats GetBikeStats(BikeType bikeType) { var stats = new BikeStats(); switch (bikeType) { case BikeType.Road: stats = new BikeStats(RoadBikeSuspension, RoadBikeSpeed, RoadBikeWeightBonus); break; case BikeType.HMTB: stats = new BikeStats(HMTBSuspension, HMTBSpeed, HMTBWeightBonus); break; case BikeType.Gravel: stats = new BikeStats(GravelBikeSuspension, GravelBikeSpeed, GravelBikeWeightBonus); break; case BikeType.FSMTB: stats = new BikeStats(FSMTBSuspension, FSMTBSpeed, FSMTBWeightBonus); break; case BikeType.EBike: stats = new BikeStats(EBikeSuspension, EBikeSpeed, EBikeWeightBonus); break; case BikeType.City: stats = new BikeStats(CityBikeSuspension, CityBikeSpeed, CityBikeWeightBonus); break; default: break; } return(stats); }
public Competitor GetCompetitor(BikeType type) { // Decide which bike to create using lazy initialisation // In otherwords don't make a new instance if we're already // got one in the collection if (_competitors.ContainsKey(type)) { return(_competitors[type]); } else { Competitor comp = null; switch (type) { case BikeType.Hybrid: comp = new HybridBikeCompetitor(); break; case BikeType.Mountain: comp = new MountainBikeCompetitor(); break; case BikeType.Road: comp = new RoadBikeCompetitor(); break; default: throw new ArgumentOutOfRangeException(String.Format("{0} is not a valid bike type", type)); } _competitors.Add(type, comp); return(comp); } }
public async Task <ActionResult <BikeTypeResponse> > AddBikeType([FromBody] AddBikeTypeRequest request) { var bikeType = new BikeType { BikeTypeName = request.BikeTypeName, BikeTypePrice = request.BikeTypePrice, BikeTypeDescription = request.BikeTypeDescription, BikeTypeImage = request.BikeTypeImage }; _context.BikeTypes.Add(bikeType); await _context.SaveChangesAsync(); var bikeTypeResponse = new BikeTypeResponse { Id = bikeType.Id, BikeTypeName = bikeType.BikeTypeName, BikeTypePrice = bikeType.BikeTypePrice, BikeTypeDescription = bikeType.BikeTypeDescription, BikeTypeImage = bikeType.BikeTypeImage }; return(CreatedAtAction(nameof(AddBikeType), new { bikeTypeId = bikeTypeResponse.Id }, bikeTypeResponse)); }
/// <summary> /// <para>Performs the Search Method: /// Search Motor Bikes. /// It creates the query string using the paramaters - can be null if the parameter is not required for the request. /// </para> /// DOES NOT REQUIRE AUTHENTICATION. /// </summary> /// <param name="searchString">One or more keywords to use in a search query.</param> /// <param name="sortOrder">Sort the returned record-set by a single specified sort order.</param> /// <param name="priceMin">Minimum price.</param> /// <param name="priceMax">Maximum price.</param> /// <param name="make"> Motorbike make.</param> /// <param name="type">Type of the Motor Bike.</param> /// <param name="yearMin"> Minimum year of manufacture.</param> /// <param name="yearMax">Maximum year of manufacture.</param> /// <param name="energySizeMin">Minimum engine size in cubic centimetres (e.g. 2000 for 2 litre engine).</param> /// <param name="energySizeMax">Maximum engine size.</param> /// <param name="dateFrom">Return only listings started from this date.</param> /// <param name="page">Page number.</param> /// <param name="rows">Number of rows per page.</param> /// <returns>MotorBikes.</returns> public MotorBikes SearchMotorBikes( string searchString, SortOrder sortOrder, decimal priceMin, decimal priceMax, string make, BikeType type, int? yearMin, int? yearMax, int? energySizeMin, int? energySizeMax, DateTime dateFrom, int? page, int? rows) { if (_search == null) { _search = new SearchMethods(_connection); } return _search.SearchMotorBikes(searchString, sortOrder, priceMin, priceMax, make, type, yearMin, yearMax, energySizeMin, energySizeMax, dateFrom, page, rows); }
public void GenerateMonthlyTrainingReportTest() { //Arrange = initialisatie objecten en kent waarden van gegevens toe aan methoden int year = 1996; int month = 1; //DB testCyclingSessions TrainingManager t = new TrainingManager(new UnitOfWork(new TrainingContextTest(false))); //Cyclingreport #region AddCyclingTraining maxDistanceSession DateTime now = new DateTime(1996, 1, 23); float distance = 257.20f; TimeSpan time = new TimeSpan(12, 05, 10); float averageSpeed = 30.00f; int averageWatt = 200; TrainingType tt = TrainingType.Endurance; string comment = "Good job"; BikeType bt = BikeType.RacingBike; t.AddCyclingTraining(now, distance, time, averageSpeed, averageWatt, tt, comment, bt); #endregion #region AddCyclingTraining2 maxSpeedSession DateTime tommorow = new DateTime(1996, 1, 24); float distance2 = 120.40f; TimeSpan time2 = new TimeSpan(6, 03, 08); float averageSpeed2 = 50.00f; int averageWatt2 = 200; TrainingType tt2 = TrainingType.Endurance; BikeType bt2 = BikeType.MountainBike; t.AddCyclingTraining(tommorow, distance2, time2, averageSpeed2, averageWatt2, tt2, comment, bt2); #endregion #region AddCyclingTraining3 maxWattSession DateTime afterTommorow = new DateTime(1996, 1, 25); float distance3 = 110.40f; TimeSpan time3 = new TimeSpan(6, 03, 08); float averageSpeed3 = 30.00f; int averageWatt3 = 400; TrainingType tt3 = TrainingType.Endurance; BikeType bt3 = BikeType.MountainBike; t.AddCyclingTraining(afterTommorow, distance3, time3, averageSpeed3, averageWatt3, tt3, comment, bt3); #endregion //RunningReport #region runningTraining maxDistanceSessionRunning DateTime now4 = new DateTime(1996, 1, 26); int distance4 = 500; TimeSpan time4 = new TimeSpan(0, 15, 20); float averageSpeed4 = 15.00f; t.AddRunningTraining(now4, distance4, time4, averageSpeed4, TrainingType.Interval, "good job!"); #endregion #region runningTraining maxSpeedSessionRunning DateTime now5 = new DateTime(1996, 1, 26, 12, 20, 30); int distance5 = 200; TimeSpan time5 = new TimeSpan(0, 20, 20); float averageSpeed5 = 25.00f; t.AddRunningTraining(now5, distance5, time5, averageSpeed5, TrainingType.Recuperation, "awesome new SpeedRecord"); #endregion //Act = roept testen method op met ingestgelde parameters Report rapport = t.GenerateMonthlyTrainingsReport(year, month); //Assert = verifieert actie van geteste methoden rapport.TimeLine.Count.Should().Be(5); rapport.Rides.Count.Should().Be(3); rapport.Runs.Count.Should().Be(2); }
private void InputSender() { int hr = int.Parse(timeWhenHr.Text); int min = int.Parse(timeWhenMin.Text); DateTime when = new DateTime(dateWhen.SelectedDate.Value.Year, dateWhen.SelectedDate.Value.Month, dateWhen.SelectedDate.Value.Day, hr, min, 0); TimeSpan time = DoubleToTimeSpan(sliderTimeSpan.Value); float?avgSpeed; if (textboxSnelheid.Text != "" && float.TryParse(textboxSnelheid.Text, out float _)) { avgSpeed = float.Parse(textboxSnelheid.Text); } else { avgSpeed = null; } TrainingType trainingType = TrainingType.Endurance; switch (comboboxTrainingType.SelectedIndex) { case 0: trainingType = TrainingType.Endurance; break; case 1: trainingType = TrainingType.Interval; break; case 2: trainingType = TrainingType.Recuperation; break; default: break; } string comments = richtextComments.Text.ToString(); if (radioFietsTraining.IsChecked == true) { float?distance; if (textboxAfstand.Text != "" && float.TryParse(textboxAfstand.Text, out float _)) { distance = float.Parse(textboxAfstand.Text); } else { distance = null; } int?avgWatt; if (textboxWattage.Text != "" && int.TryParse(textboxWattage.Text, out int _)) { avgWatt = int.Parse(textboxWattage.Text); } else { avgWatt = null; } BikeType bikeType = BikeType.CityBike; switch (comboboxFietsType.SelectedIndex) { case 0: bikeType = BikeType.IndoorBike; break; case 1: bikeType = BikeType.RacingBike; break; case 2: bikeType = BikeType.CityBike; break; case 3: bikeType = BikeType.MountainBike; break; default: break; } BackEndData.AddCyclingTraining(when, distance, time, avgSpeed, avgWatt, trainingType, bikeType, comments); } else { int distance = int.Parse(textboxAfstand.Text); BackEndData.AddRunningTraining(when, distance, time, avgSpeed, trainingType, comments); } }
private void AddBtn_Click(object sender, RoutedEventArgs e) { DateTime date = DateTime.Now; TimeSpan time = TimeSpan.Zero; int distance = 0; TimeSpan duration = TimeSpan.Zero; float speed = 0; String comment = ""; int watt = 0; TrainingType type = TrainingType.Recuperation; BikeType bicycle = BikeType.MountainBike; try { date = DateInpt.SelectedDate.Value; DateTime t = DateTime.ParseExact(Timeinput.Text, "h:mm tt", CultureInfo.InvariantCulture); time = t.TimeOfDay; date = date.Add(time); distance = Int32.Parse(DISTANCEINPUT.Text); duration = TimeSpan.Parse(DURATIONINPUT.Text); if (RecoveryR.IsChecked.Equals(true)) { type = TrainingType.Recuperation; } else if (EnduranceR.IsChecked.Equals(true)) { type = TrainingType.Endurance; } else { type = TrainingType.Interval; } if (Bike1.IsChecked.Equals(true)) { bicycle = BikeType.MountainBike; } else if (Bike2.IsChecked.Equals(true)) { bicycle = BikeType.IndoorBike; } else { bicycle = BikeType.RacingBike; } if (!string.IsNullOrWhiteSpace(COMMENTINPUT.Text)) { comment = COMMENTINPUT.Text; } if (!string.IsNullOrWhiteSpace(WATTINPUT.Text)) { watt = Int32.Parse(WATTINPUT.Text); } if (!string.IsNullOrWhiteSpace(SPEEDINPUT.Text)) { speed = float.Parse(SPEEDINPUT.Text); } } catch { MessageBox.Show("Give valid Input"); } TrainingManager person = new TrainingManager(new UnitOfWork(new TrainingContext("Production"))); if (CyclerBox.IsChecked.Equals(true)) { person.AddCyclingTraining(date, distance, time, speed, watt, type, comment, bicycle); } else { person.AddRunningTraining(date, distance, time, speed, type, comment); } MessageBox.Show("Succes!!!"); //MessageBox.Show(date.ToString() + " | " + distance.ToString() + " | " + duration.ToString() + " | " + speed + " | " + comment + " | " + type.ToString() + " | " + watt.ToString() + " | " + bicycle.ToString()); }
public Bike(string make, string model, decimal price, int year, string color, decimal mileage, string description, BitmapImage image, BikeType bodyType) : base(make, model, price, year, color, mileage, description, image) { this.type = bodyType; }
public void AddCyclingTraining(DateTime when, float?distance, TimeSpan time, float?averageSpeed, int?averageWatt, TrainingType trainingType, string comments, BikeType bikeType) { _gerry.AddCyclingTraining(when, distance, time, averageSpeed, averageWatt, trainingType, comments, bikeType); }
internal static void AddCyclingTraining(DateTime when, float?distance, TimeSpan time, float?avgSpeed, int?avgWatt, TrainingType tp, BikeType bt, string comments) { TrainingManager TM = new TrainingManager(new UnitOfWork(new TrainingContext())); TM.AddCyclingTraining(when, distance, time, avgSpeed, avgWatt, tp, comments, bt); }
private void FormSaveClickEevent(object sender, RoutedEventArgs e) { SaveButton.Content = "Saving..."; DateTime inputDate = new DateTime(); DateTime inputTime = new DateTime(); try { inputDate = InputDate.SelectedDate.Value; inputTime = InputTime.SelectedTime.Value; } catch (Exception) { MessageBox.Show("You must fill in the date and time"); return; } DateTime date = new DateTime(inputDate.Year, inputDate.Month, inputDate.Day, inputTime.Hour, inputTime.Minute, inputTime.Second); int trainingType = InputTrainingType.SelectedIndex; if (trainingType < 0) { MessageBox.Show("You must select a training type"); return; } int sportType = InputSportType.SelectedIndex; if (sportType < 0) { MessageBox.Show("You must select a sport type"); return; } int bikeType = InputBikeType.SelectedIndex; if (sportType == 1) { if (bikeType < 0) { MessageBox.Show("You must select a bike type"); return; } } if (InputLength.Text == "") { MessageBox.Show("You must fill in the distance"); return; } if (!Int32.TryParse(InputLength.Text, out int inputLength)) { MessageBox.Show("You must fill in a valid number as distance"); return; } if (inputLength <= 0) { MessageBox.Show("Distance must be greater than 0"); return; } if (InputDuration.Text == "") { MessageBox.Show("You must fill in a duration"); return; } if (!TimeSpan.TryParse(InputDuration.Text, out TimeSpan duration)) { MessageBox.Show("Duration must be a valid time format"); return; } String inputComment = InputComment.Text; TrainingType TrainingType = TrainingType.Interval; switch (trainingType) { case 0: TrainingType = TrainingType.Recuperation; break; case 1: TrainingType = TrainingType.Endurance; break; case 2: TrainingType = TrainingType.Interval; break; } try { switch (sportType) { case 0: int runSpeed = Convert.ToInt32((inputLength * 1000) / duration.TotalHours); manager.AddRunningTraining(date, inputLength, duration, runSpeed, TrainingType, inputComment); break; case 1: BikeType BikeType = BikeType.CityBike; switch (bikeType) { case 0: BikeType = BikeType.MountainBike; break; case 1: BikeType = BikeType.IndoorBike; break; case 2: BikeType = BikeType.RacingBike; break; case 3: BikeType = BikeType.CityBike; break; } int bikeSpeed = Convert.ToInt32(inputLength / duration.TotalHours); manager.AddCyclingTraining(date, (float)inputLength, duration, bikeSpeed, 100, TrainingType, inputComment, BikeType); break; default: break; } MessageBox.Show("New training has been added"); } catch (Exception) { MessageBox.Show("Something went wrong while adding new a training"); } SaveButton.Content = "Save Training"; }
public void GenerateMonthlyCyclingReportTest() { //Arrange = initialisatie objecten en kent waarden van gegevens toe aan methoden int year = 1996; int month = 1; //DB testCyclingSessions TrainingManager t = new TrainingManager(new UnitOfWork(new TrainingContextTest(false))); //Cyclingreport #region AddCyclingTraining maxDistanceSession DateTime now = new DateTime(1996, 1, 23); float distance = 257.20f; TimeSpan time = new TimeSpan(12, 05, 10); float averageSpeed = 30.00f; int averageWatt = 200; TrainingType tt = TrainingType.Endurance; string comment = "Good job"; BikeType bt = BikeType.RacingBike; t.AddCyclingTraining(now, distance, time, averageSpeed, averageWatt, tt, comment, bt); #endregion #region AddCyclingTraining2 maxSpeedSession DateTime tommorow = new DateTime(1996, 1, 24); float distance2 = 120.40f; TimeSpan time2 = new TimeSpan(6, 03, 08); float averageSpeed2 = 50.00f; int averageWatt2 = 200; TrainingType tt2 = TrainingType.Endurance; BikeType bt2 = BikeType.MountainBike; t.AddCyclingTraining(tommorow, distance2, time2, averageSpeed2, averageWatt2, tt2, comment, bt2); #endregion #region AddCyclingTraining3 maxWattSession DateTime afterTommorow = new DateTime(1996, 1, 25); float distance3 = 110.40f; TimeSpan time3 = new TimeSpan(6, 03, 08); float averageSpeed3 = 30.00f; int averageWatt3 = 400; TrainingType tt3 = TrainingType.Endurance; BikeType bt3 = BikeType.MountainBike; t.AddCyclingTraining(afterTommorow, distance3, time3, averageSpeed3, averageWatt3, tt3, comment, bt3); #endregion //Act = roept testen method op met ingestgelde parameters Report rapport = t.GenerateMonthlyCyclingReport(year, month); //Assert = verifieert actie van geteste methoden //Test findMAxSessions rapport.MaxDistanceSessionCycling.Distance.Should().Be(257.20f); rapport.MaxSpeedSessionCycling.AverageSpeed.Should().Be(50.00f); rapport.MaxWattSessionCycling.AverageWatt.Should().Be(400); //Test TotalSessions rapport.CyclingSessions.Should().Be(3); rapport.TotalCyclingDistance.Should().Be(488.00f); rapport.TotalCyclingTrainingTime.Should().Be(new TimeSpan(24, 11, 26)); //Test Timeline rapport.TimeLine.Should().NotBeEmpty(); }
/// <summary> /// <para>Performs the Search Method: /// Search Motor Bikes. /// It creates the query string using the paramaters - can be null if the parameter is not required for the request. /// </para> /// DOES NOT REQUIRE AUTHENTICATION. /// </summary> /// <param name="searchString">One or more keywords to use in a search query.</param> /// <param name="sortOrder">Sort the returned record-set by a single specified sort order.</param> /// <param name="priceMin">Minimum price.</param> /// <param name="priceMax">Maximum price.</param> /// <param name="make"> Motorbike make.</param> /// <param name="type">Type of the Motor Bike.</param> /// <param name="yearMin"> Minimum year of manufacture.</param> /// <param name="yearMax">Maximum year of manufacture.</param> /// <param name="energySizeMin">Minimum engine size in cubic centimetres (e.g. 2000 for 2 litre engine).</param> /// <param name="energySizeMax">Maximum engine size.</param> /// <param name="dateFrom">Return only listings started from this date.</param> /// <param name="page">Page number.</param> /// <param name="rows">Number of rows per page.</param> /// <returns>MotorBikes.</returns> public MotorBikes SearchMotorBikes( string searchString, SortOrder sortOrder, decimal priceMin, decimal priceMax, string make, BikeType type, int? yearMin, int? yearMax, int? energySizeMin, int? energySizeMax, DateTime dateFrom, int? page, int? rows) { var url = String.Format(Constants.Culture, "{0}/{1}/Bikes{2}", Constants.SEARCH, Constants.MOTORS, Constants.XML); _addAnd = false; var conditions = "?"; // create the parameters for the query string conditions += SearchMethods.ConstructQueryHelper(Constants.SEARCH_STRING, searchString, _addAnd); conditions += SearchMethods.ConstructQueryHelper(Constants.SORT_ORDER, sortOrder.ToString(), _addAnd); conditions += SearchMethods.ConstructQueryHelper(Constants.PRICE_MIN, string.Empty + priceMin, _addAnd); conditions += SearchMethods.ConstructQueryHelper(Constants.PRICE_MAX, string.Empty + priceMax, _addAnd); conditions += SearchMethods.ConstructQueryHelper(Constants.MAKE, make, _addAnd); conditions += SearchMethods.ConstructQueryHelper(Constants.TYPE, type.ToString(), _addAnd); conditions += SearchMethods.ConstructQueryHelper(Constants.YEAR_MIN, string.Empty + yearMin, _addAnd); conditions += SearchMethods.ConstructQueryHelper(Constants.YEAR_MAX, string.Empty + yearMax, _addAnd); conditions += SearchMethods.ConstructQueryHelper(Constants.ENERGY_SIZE_MIN, string.Empty + energySizeMin, _addAnd); conditions += SearchMethods.ConstructQueryHelper(Constants.ENERGY_SIZE_MAX, string.Empty + energySizeMax, _addAnd); conditions += SearchMethods.ConstructQueryHelper(Constants.DATE_FROM, Client.DateToStringConverter(dateFrom), _addAnd); conditions += SearchMethods.ConstructQueryHelper(Constants.PAGE, string.Empty + page, _addAnd); conditions += SearchMethods.ConstructQueryHelper(Constants.ROWS, string.Empty + rows, _addAnd); // add the parameters to the query string if there are any if (conditions.Equals("?")) { url += conditions; } // perform the request return this.SearchMotorBikes(url); }
public Bike(BikeType bikeType) { this.bikeType = bikeType; this.partList = new List<Part>(); }
public Bike(string model, string make, BikeType type, int price, int year, int mile, double size, string des, string color, string socure, string img) : base(model, make, price, year, mile, size, des, color, socure, img) { BodyType = type; }
private void btnAddBike_Click(object sender, RoutedEventArgs e) { bool speedFlag = double.TryParse(bikeAvgSpeed.Text, out double averageSpeed); float?nullableAverageSpeed = (averageSpeed == 0) ? null : (float?)averageSpeed; bool wattFlag; int? averageWatt = null; if (avgWatt.Text != String.Empty) { wattFlag = int.TryParse(avgWatt.Text, out int notNullAverageWatt); averageWatt = notNullAverageWatt; } BikeType bikeType = BikeType.CityBike; bool typeFlag = false; if (this.bikeType.SelectedItem != null) { bikeType = (BikeType)this.bikeType.SelectedItem; typeFlag = true; } bool distanceFlag = false; double?distance = null; if (bikeAfstand.Text != String.Empty) { distanceFlag = double.TryParse(bikeAfstand.Text, out double notNullDistance); distance = notNullDistance; } TrainingType trainingType = TrainingType.Endurance; bool trainigsFlag = false; if (bikeTrainingType.SelectedItem != null) { trainingType = (TrainingType)bikeTrainingType.SelectedItem; trainigsFlag = true; } var comment = bikeComment.Text; bool timeFlag = TimeSpan.TryParseExact(bikeTijdsduur.Text, "h\\:mm", CultureInfo.InvariantCulture, TimeSpanStyles.None, out var time); bool startTimeFlag = false; DateTime startTijd = DateTime.Now; if (dpStartTijd.Text != null) { startTijd = DateTime.Parse((dpStartTijd.Text)); startTimeFlag = true; } if (typeFlag && trainigsFlag && timeFlag && startTimeFlag) { try { _tm.AddCyclingTraining(startTijd, (float?)distance, time, nullableAverageSpeed, averageWatt, trainingType, comment, bikeType); } catch (Exception ex) { MessageBox.Show("An execption just occurred: " + ex.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error); return; } MessageBox.Show("Record has been added", "Succes", MessageBoxButton.OK); var window = new MainWindow(); window.Show(); this.Close(); } else { if (!speedFlag) { bikeAvgSpeed.Text = String.Empty; } if (!distanceFlag) { bikeAfstand.Text = String.Empty; } if (!timeFlag) { bikeTijdsduur.Text = String.Empty; } MessageBox.Show("You didn't pass the right info", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } }
public Part() { bikeType = new BikeType(); this.bike = new Bike(bikeType); }
public Bike(string name, BikeType type) { this.Name = name; this.Type = type; }
public abstract void FillOrder(BikeType type);
public CyclingSession(DateTime when, float?distance, TimeSpan time, float?averageSpeed, int?averageWatt, TrainingType trainingType, string comments, BikeType bikeType) { When = when; Distance = distance; Time = time; if ((averageSpeed == null) && (distance != null)) { AverageSpeed = (float)(distance / time.TotalHours); } else { AverageSpeed = averageSpeed; } AverageWatt = averageWatt; TrainingType = trainingType; Comments = comments; BikeType = bikeType; }
public Motorcycle(string name, BikeType bikeType) { Name = name; BikeType = bikeType; Initializer(); }