Hi,
I'm new to c# and have spent the last day or so trying to change where this info is pulled from for creating a PDF within our application.
Below within the **** I need to change the data to look at a QuoteOption table instead of a Quote table.
I have traced the below code back to the red line below.
As i'm now running out of ideas just thought I would post here for some beginners help!
Thanks
_options = (optionService.GetQuoteOptions(_quote.Id) ?? new List<QuoteOptionDto>()).ToList();
foreach (var o in _options)
{
decimal price = _quote.FastTrack ? o.FastTrackPrice ?? 0 : o.ListPrice ?? 0;
tblPriceList.AddCell(DataCell(o.Quantity + " X " + ptionDescription));
tblPriceList.AddCell(DataCell(o.Quantity * price, 2));
**** decimal chassisCost = o.Quantity * (o.ChassisMaterialCost ?? 0); ****
decimal bodyCost = o.Quantity * (o.BodyMaterialCost?? 0);
tblPriceList.AddCell(DataCell(chassisCost + bodyCost, 2));
tblPriceList.AddCell(DataCell(o.Quantity * o.BodyHours ?? 0, 2));
tblPriceList.AddCell(DataCell(o.Quantity * o.ChassisHours ?? 0, 2));
}
//Total trailer material cost
decimal totalMaterial = _options.Sum(x => (x.ChassisMaterialCost ?? 0) * x.Quantity)
+ _options.Sum(x => (x.BodyMaterialCost ?? 0) * x.Quantity)
+ (_trailer.ChassisMaterialCost ?? 0)
+ (_trailer.BodyMaterialCost ?? 0);
//Total body hrs
decimal totalBodyHours = _trailer.BodyHours.GetValueOrDefault()
+ _options.Sum(x => x.Quantity * x.BodyHours.GetValueOrDefault());
//Total chassis hrs
decimal totalChassisHours = _trailer.ChassisHours.GetValueOrDefault()
+ _options.Sum(x => x.Quantity * x.ChassisHours.GetValueOrDefault());
//Total body + chassis hrs
decimal labourHours = totalChassisHours + totalBodyHours;
I'm new to c# and have spent the last day or so trying to change where this info is pulled from for creating a PDF within our application.
Below within the **** I need to change the data to look at a QuoteOption table instead of a Quote table.
I have traced the below code back to the red line below.
As i'm now running out of ideas just thought I would post here for some beginners help!
Thanks
_options = (optionService.GetQuoteOptions(_quote.Id) ?? new List<QuoteOptionDto>()).ToList();
foreach (var o in _options)
{
decimal price = _quote.FastTrack ? o.FastTrackPrice ?? 0 : o.ListPrice ?? 0;
tblPriceList.AddCell(DataCell(o.Quantity + " X " + ptionDescription));
tblPriceList.AddCell(DataCell(o.Quantity * price, 2));
**** decimal chassisCost = o.Quantity * (o.ChassisMaterialCost ?? 0); ****
decimal bodyCost = o.Quantity * (o.BodyMaterialCost?? 0);
tblPriceList.AddCell(DataCell(chassisCost + bodyCost, 2));
tblPriceList.AddCell(DataCell(o.Quantity * o.BodyHours ?? 0, 2));
tblPriceList.AddCell(DataCell(o.Quantity * o.ChassisHours ?? 0, 2));
}
//Total trailer material cost
decimal totalMaterial = _options.Sum(x => (x.ChassisMaterialCost ?? 0) * x.Quantity)
+ _options.Sum(x => (x.BodyMaterialCost ?? 0) * x.Quantity)
+ (_trailer.ChassisMaterialCost ?? 0)
+ (_trailer.BodyMaterialCost ?? 0);
//Total body hrs
decimal totalBodyHours = _trailer.BodyHours.GetValueOrDefault()
+ _options.Sum(x => x.Quantity * x.BodyHours.GetValueOrDefault());
//Total chassis hrs
decimal totalChassisHours = _trailer.ChassisHours.GetValueOrDefault()
+ _options.Sum(x => x.Quantity * x.ChassisHours.GetValueOrDefault());
//Total body + chassis hrs
decimal labourHours = totalChassisHours + totalBodyHours;