/// <method> /// SearchByOffenceType() returns all driving offences /// belonging to a specified search criteria of /// vehicle and offence type. /// </method> public List<GetDriverOffenceUI> SearchByVO(string registration, string description) { List<DriverOffence> driverOffencesDB = _DAL.ListOfDriverOffences(); List<GetDriverOffenceUI> driverOffencesUI = new List<GetDriverOffenceUI>(); GetDriverOffenceUI _offenceUI = new GetDriverOffenceUI(); //loop through all driving offences. //if driving offence matches vehicle and offence type //search criteria then store the driving offence. foreach (DriverOffence driverOffence in driverOffencesDB) { if (driverOffence.VehicleDetails.VdRegistration == registration && driverOffence.ListedOffence.LoDesc == description) { //driver offence info. _offenceUI.id = driverOffence.Id; _offenceUI.status = driverOffence.doStatus.ToString(); _offenceUI.location = driverOffence.doLocation.ToString(); _offenceUI.offenceDate = driverOffence.doOffenceDate; //offence details _offenceUI.description = driverOffence.ListedOffence.LoDesc.ToString(); //driver details info. _offenceUI.LicenceNo = driverOffence.DriverDetail.DdLicenceNo.ToString(); _offenceUI.FName = driverOffence.DriverDetail.DdFName.ToString(); _offenceUI.SName = driverOffence.DriverDetail.DdSName.ToString(); _offenceUI.LicenceStatus = driverOffence.DriverDetail.DdLicenceStatus.ToString(); //vehicle details _offenceUI.Registration = driverOffence.VehicleDetails.VdRegistration.ToString(); driverOffencesUI.Add(_offenceUI); } } return driverOffencesUI; }
/// <method> /// GetOffences() returns a list of all active driver offences types in the database /// </method> public List<GetDriverOffenceUI> GetOffences() { //Get driver offences from database //Iterate through the list //For all offences with status=delete add to _activeOffences //return _activeOffences List<DriverOffence> _offencesDB = _DAL.ListOfDriverOffences(); List<GetDriverOffenceUI> _activeOffences = new List<GetDriverOffenceUI>(); GetDriverOffenceUI _offenceUI = new GetDriverOffenceUI(); foreach (DriverOffence driverOffence in _offencesDB) { if (driverOffence.doStatus != "Deleted") { //driver offence info. _offenceUI.id = driverOffence.Id; _offenceUI.status = driverOffence.doStatus.ToString(); _offenceUI.location = driverOffence.doLocation.ToString(); _offenceUI.offenceDate = driverOffence.doOffenceDate; //offence details _offenceUI.description = driverOffence.ListedOffence.LoDesc.ToString(); //driver details info. _offenceUI.LicenceNo = driverOffence.DriverDetail.DdLicenceNo.ToString(); _offenceUI.FName = driverOffence.DriverDetail.DdFName.ToString(); _offenceUI.SName = driverOffence.DriverDetail.DdSName.ToString(); _offenceUI.LicenceStatus = driverOffence.DriverDetail.DdLicenceStatus.ToString(); //vehicle details _offenceUI.Registration = driverOffence.VehicleDetails.VdRegistration.ToString(); _activeOffences.Add(_offenceUI); } } return _activeOffences; }