Esempio n. 1
0
        private ReportDetailsViewModel RetrieveReportMasterData(TruckInspection inspectionRecord)
        {
            if (inspectionRecord != null)
            {
                return(new ReportDetailsViewModel
                {
                    Id = inspectionRecord.Id,
                    DriverName = inspectionRecord.Driver.FullName,
                    TruckNumber = inspectionRecord.Truck.TruckNumber.ToString(),
                    SubmissionDate = inspectionRecord.CreationDate.ToString(),
                    CurrentMileage = inspectionRecord.Mileage.ToString(),
                    Comments = inspectionRecord.Comments
                });
            }

            return(new ReportDetailsViewModel());
        }
Esempio n. 2
0
        private string AddMasterDataToTruckInspectionTableAndReturnTruckInspectionId(TruckInspectionViewModel truckInspection)
        {
            var inspectionDataToInsert = new TruckInspection();

            inspectionDataToInsert.DriverId = truckInspection.DriverId;
            inspectionDataToInsert.TruckId  = truckInspection.TruckId;
            var currentMileageConvertedToString = ConvertStringToInt(truckInspection.CurrentMileage);

            //Check that string mileage coming from UI is a valid integer
            if (currentMileageConvertedToString != -1)
            {
                inspectionDataToInsert.Mileage = currentMileageConvertedToString;
            }
            else
            {
                _logger.Warning("There was an error converting CurrentMileage from String to Int in TruckInspectionService");
            }

            inspectionDataToInsert.Comments = truckInspection.Comments;
            _truckInspectionContext.Insert(inspectionDataToInsert);
            return(inspectionDataToInsert.Id);
        }