public long InsertWSREInspectionRecord(WRESSyncModel equip) { try { BLL.Core.Domain.TTDevUser user = new BLL.Core.Domain.TTDevUser(new DAL.SharedContext(), 0); ////////////////// // WSREs table DAL.WSRE WSREsRecord = new DAL.WSRE(); WSREsRecord.Date = DateTime.Now; WSREsRecord.SystemId = equip.SystemId; WSREsRecord.JobsiteId = equip.JobsiteId; WSREsRecord.InspectorId = user.GetUserAutoById(equip.InspectorId); WSREsRecord.JobNumber = equip.JobNumber; WSREsRecord.OldTagNumber = equip.OldTagNumber; WSREsRecord.OverallComment = equip.OverallComment; WSREsRecord.OverallRecommendation = equip.OverallRecommendation; WSREsRecord.StatusId = 1; WSREsRecord.CustomerReference = equip.CustomerReference; WSREsRecord.SystemLife = new BLL.Core.Domain.UCSystem(new DAL.UndercarriageContext(), (int)WSREsRecord.SystemId).GetSystemLife(DateTime.Now); _WSREs.Add(WSREsRecord); // COMMIT _context.SaveChanges(); _WSREId = WSREsRecord.Id; } catch (Exception e) { // Sync failed, roll back RollbackWSREInfo(); return(0); } return(_WSREId); }
public Boolean SaveWSREInfo(WRESSyncModel equip) { try { BLL.Core.Domain.TTDevUser user = new BLL.Core.Domain.TTDevUser(new DAL.SharedContext(), 0); //////////////////// //// WSREs table //DAL.WSRE WSREsRecord = new DAL.WSRE(); //WSREsRecord.Date = DateTime.Now; //WSREsRecord.SystemId = equip.SystemId; //WSREsRecord.JobsiteId = equip.JobsiteId; //WSREsRecord.InspectorId = user.GetUserAutoById(equip.InspectorId); //WSREsRecord.JobNumber = equip.JobNumber; //WSREsRecord.OldTagNumber = equip.OldTagNumber; //WSREsRecord.OverallComment = equip.OverallComment; //WSREsRecord.OverallRecommendation = equip.OverallRecommendation; //WSREsRecord.StatusId = 1; //WSREsRecord.CustomerReference = equip.CustomerReference; //WSREsRecord.SystemLife = new BLL.Core.Domain.UCSystem(new DAL.UndercarriageContext(), (int)WSREsRecord.SystemId).GetSystemLife(DateTime.Now); //_WSREs.Add(WSREsRecord); //// COMMIT //_context.SaveChanges(); //_WSREId = WSREsRecord.Id; _WSREId = equip.serverInspectionId; ///////////////////////////// // WSREInitialImages table foreach (var item in equip.InitialImages) { DAL.WSREInitialImage record = new DAL.WSREInitialImage(); record.WSREId = _WSREId; SaveWSREInitialImages(record, item); } ////////////////////////////////// // WSREComponentRecords table foreach (var item in equip.ComponentRecords) { DAL.WSREComponentRecord record = new DAL.WSREComponentRecord(); record.WSREId = _WSREId; SaveWSREComponentRecords(record, item); } ////////////////////////////////// // WSRECrackTest table DAL.WSRECrackTest recordCrack = new DAL.WSRECrackTest(); recordCrack.WSREId = _WSREId; SaveWSRECrackTestsRecords(recordCrack, equip); ////////////////////////////// // DipTests tables foreach (var item in equip.DipTestRecords) { DAL.WSREDipTest recordDipTest = new DAL.WSREDipTest(); recordDipTest.WSREId = _WSREId; SaveWSREDipTestsRecords(recordDipTest, item); } // COMMIT _context.SaveChanges(); ///////////////////////// // Update "OverallEval" UpdateOverallEval(); } catch (Exception e) { // Sync failed, roll back RollbackWSREInfo(); return(false); } return(true); }