public GenericFeatures DeleteGenericFeatures(int genericFeaturesID) { GenericFeatures dbEntry = context.GenericFeaturesList .FirstOrDefault(p => p.GenericFeaturesID == genericFeaturesID); if (dbEntry != null) { context.GenericFeaturesList.Remove(dbEntry); context.SaveChanges(); } return(dbEntry); }
public void SaveGenericFeatures(GenericFeatures genericFeatures) { if (genericFeatures.GenericFeaturesID == 0) { context.GenericFeaturesList.Add(genericFeatures); } else { GenericFeatures dbEntry = context.GenericFeaturesList .FirstOrDefault(p => p.GenericFeaturesID == genericFeatures.GenericFeaturesID); if (dbEntry != null) { dbEntry.GenericFeaturesID = dbEntry.GenericFeaturesID; dbEntry.JobID = dbEntry.JobID; dbEntry.FRON2 = dbEntry.FRON2; dbEntry.Attendant = dbEntry.Attendant; dbEntry.CarToLobby = dbEntry.CarToLobby; dbEntry.EQ = dbEntry.EQ; dbEntry.EMT = dbEntry.EMT; dbEntry.EP = dbEntry.EP; dbEntry.EPVoltage = dbEntry.EPVoltage; dbEntry.EPOtherCars = dbEntry.EPOtherCars; dbEntry.EPCarsNumber = dbEntry.EPCarsNumber; dbEntry.EPContact = dbEntry.EPContact; dbEntry.PTI = dbEntry.PTI; dbEntry.EPSelect = dbEntry.EPSelect; dbEntry.FLO = dbEntry.FLO; dbEntry.Hosp = dbEntry.Hosp; dbEntry.Ind = dbEntry.Ind; dbEntry.INA = dbEntry.INA; dbEntry.TopAccess = dbEntry.TopAccess; dbEntry.TopAccessLocation = dbEntry.TopAccessLocation; dbEntry.BottomAccess = dbEntry.BottomAccess; dbEntry.BottomAccessLocation = dbEntry.BottomAccessLocation; dbEntry.INCP = dbEntry.INCP; dbEntry.INCPButtons = dbEntry.INCPButtons; dbEntry.CTINSPST = dbEntry.CTINSPST; dbEntry.Roped = dbEntry.Roped; dbEntry.GovModel = dbEntry.GovModel; dbEntry.LoadWeigher = dbEntry.LoadWeigher; dbEntry.SwitchStyle = dbEntry.SwitchStyle; dbEntry.Monitoring = dbEntry.Monitoring; dbEntry.CallEnable = dbEntry.CallEnable; dbEntry.CarCallCodeSecurity = dbEntry.CarCallCodeSecurity; dbEntry.SpecialInstructions = dbEntry.SpecialInstructions; } else { context.GenericFeaturesList.Add(genericFeatures); } } context.SaveChanges(); }
public Job DeleteEngJob(int JobID) { Job dbEntry = context.Jobs .FirstOrDefault(p => p.JobID == JobID); JobExtension jobExtension = context.JobsExtensions .FirstOrDefault(p => p.JobID == JobID); HydroSpecific hydroSpecific = context.HydroSpecifics .FirstOrDefault(p => p.JobID == JobID); GenericFeatures genericFeatures = context.GenericFeaturesList .FirstOrDefault(p => p.JobID == JobID); Indicator indicator = context.Indicators .FirstOrDefault(p => p.JobID == JobID); HoistWayData hoistWayData = context.HoistWayDatas .FirstOrDefault(p => p.JobID == JobID); if (dbEntry != null) { context.Jobs.Remove(dbEntry); context.SaveChanges(); } if (jobExtension != null) { context.JobsExtensions.Remove(jobExtension); context.SaveChanges(); } if (hydroSpecific != null) { context.HydroSpecifics.Remove(hydroSpecific); context.SaveChanges(); } if (genericFeatures != null) { context.GenericFeaturesList.Remove(genericFeatures); context.SaveChanges(); } if (indicator != null) { context.Indicators.Remove(indicator); context.SaveChanges(); } if (hoistWayData != null) { context.HoistWayDatas.Remove(hoistWayData); context.SaveChanges(); } return(dbEntry); }
public void SaveEngJobView(JobViewModel viewModelToSave) { SaveJob(viewModelToSave.CurrentJob); if (viewModelToSave.CurrentJobExtension != null) { if (viewModelToSave.CurrentJobExtension.JobID != 0) { JobExtension jobExtension = JobsExtensions.FirstOrDefault(j => j.JobID == viewModelToSave.CurrentJobExtension.JobID); if (jobExtension == null) { SaveJobExtension(viewModelToSave.CurrentJobExtension); } else { viewModelToSave.CurrentJobExtension.JobExtensionID = jobExtension.JobExtensionID; SaveJobExtension(viewModelToSave.CurrentJobExtension); } } } if (viewModelToSave.CurrentHydroSpecific != null) { if (viewModelToSave.CurrentHydroSpecific.JobID != 0) { HydroSpecific hydroSpecific = HydroSpecifics.FirstOrDefault(j => j.JobID == viewModelToSave.CurrentHydroSpecific.JobID); if (hydroSpecific == null) { SaveHydroSpecific(viewModelToSave.CurrentHydroSpecific); } else { viewModelToSave.CurrentHydroSpecific.HydroSpecificID = hydroSpecific.HydroSpecificID; SaveHydroSpecific(viewModelToSave.CurrentHydroSpecific); } } } if (viewModelToSave.CurrentGenericFeatures != null) { if (viewModelToSave.CurrentGenericFeatures.JobID != 0) { GenericFeatures genericFeatures = GenericFeaturesList.FirstOrDefault(j => j.JobID == viewModelToSave.CurrentGenericFeatures.JobID); if (genericFeatures == null) { SaveGenericFeatures(viewModelToSave.CurrentGenericFeatures); } else { viewModelToSave.CurrentGenericFeatures.GenericFeaturesID = genericFeatures.GenericFeaturesID; SaveGenericFeatures(viewModelToSave.CurrentGenericFeatures); } } } if (viewModelToSave.CurrentIndicator != null) { if (viewModelToSave.CurrentIndicator.JobID != 0) { Indicator indicator = Indicators.FirstOrDefault(j => j.JobID == viewModelToSave.CurrentIndicator.JobID); if (indicator == null) { SaveIndicator(viewModelToSave.CurrentIndicator); } else { viewModelToSave.CurrentIndicator.IndicatorID = indicator.IndicatorID; SaveIndicator(viewModelToSave.CurrentIndicator); } } } if (viewModelToSave.CurrentHoistWayData != null) { if (viewModelToSave.CurrentHoistWayData.JobID != 0) { HoistWayData hoistway = HoistWayDatas.FirstOrDefault(j => j.JobID == viewModelToSave.CurrentHoistWayData.JobID); if (hoistway == null) { SaveHoistWayData(viewModelToSave.CurrentHoistWayData); } else { viewModelToSave.CurrentHoistWayData.HoistWayDataID = hoistway.HoistWayDataID; SaveHoistWayData(viewModelToSave.CurrentHoistWayData); } } } }