public TankerData GetTankerDataByID(string tankerID) { TankerData tankerRetData = new TankerData(); List <Tanker> tankerList = new List <Tanker>(); List <DailyTankerReading> dailyTankerReadingList = new List <DailyTankerReading>(); Fuel fuel = new Fuel(); BAL.BAL_Tanker bAL_Tanker = new BAL.BAL_Tanker(); tankerList = bAL_Tanker.GetTankerList(); dailyTankerReadingList = bAL_Tanker.GetDailyTankerReading(); foreach (Tanker tanker in tankerList) { if (Convert.ToString(tanker.Id) == tankerID) { TankerData tankerData = new TankerData(); tankerData.Id = tanker.Id; tankerData.Name = tanker.Name; tankerData.Size = tanker.Size; tankerData.Description = tanker.Description; tankerData.FuelTypeID = tanker.FuelTypeId; fuel = bAL_Tanker.GetFuelByFuelID(tankerData.FuelTypeID); tankerData.FuelType = fuel.Type; foreach (DailyTankerReading dailyTankerReading in dailyTankerReadingList) { if (dailyTankerReading.TankerId == tanker.Id) { tankerData.DayStartReading = dailyTankerReading.DailyStartReading; tankerData.DayEndReading = dailyTankerReading.DailyEndReading; break; } else { continue; } } tankerRetData = tankerData; break; } else { continue; } } return(tankerRetData); }
public List <TankerData> GetTankerData() { List <TankerData> list = new List <TankerData>(); List <Tanker> tankerList = new List <Tanker>(); List <DailyTankerReading> dailyTankerReadingList = new List <DailyTankerReading>(); Fuel fuel = new Fuel(); BAL.BAL_Tanker bAL_Tanker = new BAL.BAL_Tanker(); tankerList = bAL_Tanker.GetTankerList(); dailyTankerReadingList = bAL_Tanker.GetDailyTankerReading(); foreach (Tanker tanker in tankerList) { TankerData tankerData = new TankerData(); tankerData.Id = tanker.Id; tankerData.Name = tanker.Name; tankerData.Size = tanker.Size; tankerData.Description = tanker.Description; tankerData.FuelTypeID = tanker.FuelTypeId; tankerData.Date = tanker.CreatedOn; fuel = bAL_Tanker.GetFuelByFuelID(tankerData.FuelTypeID); tankerData.FuelType = fuel.Type; foreach (DailyTankerReading dailyTankerReading in dailyTankerReadingList) { if (dailyTankerReading.TankerId == tanker.Id) { tankerData.DayStartReading = dailyTankerReading.DailyStartReading; tankerData.DayEndReading = dailyTankerReading.DailyEndReading; break; } else { continue; } } list.Add(tankerData); } return(list); }