public HorseTip(string horseName, RaceCourses racecourse, DateTime dateOfRace, decimal amountWonOrLost, bool raceWon) { BetIdNo = idIncrement++; HorseName = horseName; Racecourse = racecourse; DateOfRace = dateOfRace; AmountWonOrLost = amountWonOrLost; RaceWon = raceWon; Outcome = RaceWon ? "Won" : "Lost"; }
//The error property is used to target and display the correct error type and request the a valid input. If the error type is none then the valid propeties //are used to construct a horseTip. /// <summary> /// A Validator object that takes in data to validate a horse bet and provides an error report upon construction. /// </summary> /// <param name="horseName"></param> /// <param name="raceCourse"></param> /// <param name="stringDate"></param> /// <param name="stringAmount"></param> /// <param name="raceWon"></param> public HorseTipDataValidator(string horseName, RaceCourses raceCourse, string stringDate, string stringAmount) { decimal amount = 0; error errorType = error.none; if (String.IsNullOrWhiteSpace(horseName)) { errorType = error.name; } else { ValidHorseName = horseName; if ((ValidRacecourse = raceCourse) == (RaceCourses)(-1)) { errorType = error.course; } else { if ((!DateTime.TryParseExact(stringDate, "dd/MM/yyyy", CultureInfo.GetCultureInfo("ie-IE"), DateTimeStyles.None, out DateTime dateOfRace)) || dateOfRace > DateTime.Now) { errorType = error.date; ValidDateOfRace = new DateTime(); }