public int SaveTracker(ClsTracker objSave, ClsCarFleet clsCarFleet) { try { using (TransactionScope scope = new TransactionScope()) { using (this.objDataContext = new TrackerDataContext(Functions.StrConnection)) { var result = this.objDataContext.InsertOrUpdateTracker(objSave.inId, objSave.strTripStart, objSave.strTripEnd, objSave.strLocationStart, objSave.strLocationEnd, objSave.strReasonRemarks, objSave.inKmStart, objSave.inKmEnd, objSave.inKmDriven, objSave.inFuelStart, objSave.inFuelEnd, mySession.Current.UserId, objSave.strEntryMethod, true, objSave.blActive, PageMaster.Tracker.ToString().intSafe(), objSave.inCarId, objSave.lgReasonId, null, null, objSave.lgCompanyId, clsCarFleet.strReg, clsCarFleet.strCode, mySession.Current.Firstname, mySession.Current.Lastname) .FirstOrDefault(); if (result != null) { objSave.inId = result.InsertedId; } } scope.Complete(); } return(objSave.inId); } catch (Exception ex) { Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Tracker, mySession.Current.UserId); return(0); } }
public ClsTracker GetTrackerByTrackerId(long lgTrackerId) { ClsTracker objClsTracker = new ClsTracker(); try { using (this.objDataContext = new TrackerDataContext(Functions.StrConnection)) { GetTrackerByIdResult item = this.objDataContext.GetTrackerById(lgTrackerId).ToList().FirstOrDefault(); if (item != null) { objClsTracker.inId = item.ID; objClsTracker.inCarId = item.Car_Id ?? 0; objClsTracker.strTripStart = item.Trip_Start.Replace(' ', '/'); objClsTracker.strTripEnd = item.Trip_End.Replace(' ', '/'); objClsTracker.strLocationStart = item.Location_Start; objClsTracker.strLocationEnd = item.Location_End; objClsTracker.strReasonRemarks = item.Reason_Remarks; objClsTracker.inKmStart = item.Km_Start; objClsTracker.inKmEnd = item.Km_End; objClsTracker.inKmDriven = item.Km_Driven; objClsTracker.inFuelStart = item.Fuel_Start; objClsTracker.inFuelEnd = item.Fuel_End; objClsTracker.lgUserId = item.User_Id; objClsTracker.strEntryDatetime = item.Entry_Datetime.Replace(' ', '/'); objClsTracker.strEntryMethod = item.Entry_Method; objClsTracker.blEditable = item.Editable; objClsTracker.blActive = item.Active; objClsTracker.lgReasonId = item.Reason_Id ?? 0; objClsTracker.lgCompanyId = item.CompanyId ?? 0; } } } catch (Exception ex) { Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Tracker, mySession.Current.UserId); } return(objClsTracker); }