Esempio n. 1
0
        //===================================================================================
        private FuelReport getYesterdayLastFuelReport(IFuelReportDomainService fuelReportDomainService)
        {
            IOrderedEnumerable<FuelReport> fuelReportsOfYesterday =
                fuelReportDomainService.GetFuelReportsFromYesterday(this)
                    .OrderBy(fr => fr.EventDate);//The ordering is used to find the last report from previous day till current Report.

            return fuelReportsOfYesterday.LastOrDefault();
        }
Esempio n. 2
0
        //===================================================================================
        /// <summary>
        /// BR_FR39
        /// </summary>
        private void validateFuelReportsOfPreviousDayForMandatoryType(
            IFuelReportDomainService fuelReportDomainService,
            IGoodDomainService goodDomainService)
        {
            return;
            var fuelReportsOfYesterday = fuelReportDomainService.GetFuelReportsFromYesterday(this);

            foreach (var yesterdayFuelReport in fuelReportsOfYesterday)
            {
                var mandatoryGoods = goodDomainService.GetMandatoryVesselGoods(this.VesselInCompanyId, yesterdayFuelReport.EventDate);

                //Validate the availability of all mandatory goods for previous day fuel report.
                if (mandatoryGoods.Count(
                    mg =>
                        !yesterdayFuelReport.FuelReportDetails.
                            Select(frd => frd.Good.Id).Contains(mg.Id)) > 0                    )
                    throw new BusinessRuleException("BR_FR39", "Some mandatory fuels not found in fuel report of yesterday.");
            }
        }
Esempio n. 3
0
        //===================================================================================
        public void UpdateConsumption(IFuelReportDomainService fuelReportDomainService)
        {
            //validatePreviousFuelReportsToBeFinalApproved(fuelReportDomainService);

            var previousFuelReports = fuelReportDomainService.GetFuelReportsFromYesterday(this);

            var previousFuelReport = previousFuelReports.LastOrDefault();

            if (previousFuelReport != null)
            {
                foreach (var fuelReportDetail in this.FuelReportDetails)
                {
                    var relevantFeulReportDetailOfPreviousDay = previousFuelReport.FuelReportDetails.FirstOrDefault(frd => frd.GoodId == fuelReportDetail.GoodId);

                    if (relevantFeulReportDetailOfPreviousDay != null)
                    {
                        fuelReportDetail.UpdateConsumption(relevantFeulReportDetailOfPreviousDay);
                    }
                }
            }
        }