public static List <MasterReport> GetList() { List <MasterReport> items = new List <MasterReport>(); foreach (var item in TripBl.GetList()) { MasterReport reportData = new MasterReport(); Refill r = new RefillBl().GetById(item.RefillId); Vehicle v = new VehicleBl().GetById(item.VehicleId); Driver d = new DriverBl().GetById(item.DriverId); string closed = ""; reportData.DateTimeStart = string.Format("{0}", item.DateTimeStart.ToString("dd/MM/yy,hh:mm tt")); reportData.DateTimeEnd = string.Format("{0}", item.DateTimeEnd.ToString("dd/MM/yy,hh:mm tt")); reportData.DriverName = d.FullName; reportData.DriverId = d.Id; reportData.VehicleName = string.Format("{0}({1})", v.Name, v.RegistrationNumber); reportData.VehicleId = v.Id; reportData.Refill = string.Format("Refill No: {5}\nDate: {0}\nAmount: ${1}\nLiterage: {2}L\nPerfo': {3}km/l\nStatus: {4}", r.DateAndTime.ToString("dd/MM/yy "), r.Amount, r.Litreage, (RefillBl.TotalMileage(r.Id) / (decimal)r.Litreage).ToString("N2"), closed = r.Closed ? "Closed" : "Open", r.Id); reportData.RefillId = r.Id; reportData.MileageStart = item.MileageStart; reportData.MileageEnd = item.MileageEnd; reportData.MileageTravelled = (item.MileageEnd - item.MileageStart); reportData.TripDetails = item.TripDetails; reportData.ExpenseAccount = item.ExpenseAccount; reportData.Cost = (reportData.MileageTravelled / RefillBl.TotalMileage(r.Id)) * r.Amount; items.Add(reportData); } return(items); }
public static List <TripData> GetList() { List <TripData> items = new List <TripData>(); foreach (var item in TripBl.GetList()) { TripData tripData = new TripData(); tripData.Id = item.Id; tripData.DateStart = item.DateTimeStart.ToString("dddd dd MMM yyyy"); tripData.TimeStart = item.DateTimeStart.ToString("hh:mm tt"); tripData.DateEnd = item.DateTimeEnd.ToString("dddd dd MMM yyyy"); tripData.TimeEnd = item.DateTimeEnd.ToString("hh:mm tt"); tripData.DriverId = item.DriverId; tripData.DriverName = new DriverBl().GetById(item.DriverId).FullName; tripData.VehicleId = item.VehicleId; tripData.VehicleName = string.Format("{0}({1})", new VehicleBl().GetById(item.VehicleId).Name, new VehicleBl().GetById(item.VehicleId).RegistrationNumber); tripData.RefillDate = new RefillBl().GetById(item.RefillId).DateAndTime.ToString("dddd dd MMM yyyy"); tripData.MileageStart = item.MileageStart; tripData.MileageEnd = item.MileageEnd; tripData.TripDetails = item.TripDetails; tripData.ExpenseAccount = item.ExpenseAccount; items.Add(tripData); } return(items); }