public HydroSpecific DeleteHydroSpecific(int hydroSpecificID)
        {
            HydroSpecific dbEntry = context.HydroSpecifics
                                    .FirstOrDefault(p => p.HydroSpecificID == hydroSpecificID);

            if (dbEntry != null)
            {
                context.HydroSpecifics.Remove(dbEntry);
                context.SaveChanges();
            }
            return(dbEntry);
        }
        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 SaveHydroSpecific(HydroSpecific hydroSpecific)
 {
     if (hydroSpecific.HydroSpecificID == 0)
     {
         context.HydroSpecifics.Add(hydroSpecific);
     }
     else
     {
         HydroSpecific dbEntry = context.HydroSpecifics
                                 .FirstOrDefault(p => p.HydroSpecificID == hydroSpecific.HydroSpecificID);
         if (dbEntry != null)
         {
             dbEntry.JobID        = hydroSpecific.JobID;
             dbEntry.Starter      = hydroSpecific.Starter;
             dbEntry.HP           = hydroSpecific.HP;
             dbEntry.FLA          = hydroSpecific.FLA;
             dbEntry.SPH          = hydroSpecific.SPH;
             dbEntry.MotorsNum    = hydroSpecific.MotorsNum;
             dbEntry.ValveBrand   = hydroSpecific.ValveBrand;
             dbEntry.ValveModel   = hydroSpecific.ValveModel;
             dbEntry.ValveCoils   = hydroSpecific.ValveCoils;
             dbEntry.ValveNum     = hydroSpecific.ValveNum;
             dbEntry.ValveVoltage = hydroSpecific.ValveVoltage;
             dbEntry.Battery      = hydroSpecific.Battery;
             dbEntry.BatteryBrand = hydroSpecific.BatteryBrand;
             dbEntry.LifeJacket   = hydroSpecific.LifeJacket;
             dbEntry.LOS          = hydroSpecific.LOS;
             dbEntry.OilCool      = hydroSpecific.OilCool;
             dbEntry.OilTank      = hydroSpecific.OilTank;
             dbEntry.PSS          = hydroSpecific.PSS;
             dbEntry.Resync       = hydroSpecific.Resync;
             dbEntry.Roped        = hydroSpecific.Roped;
             dbEntry.VCI          = hydroSpecific.VCI;
         }
     }
     context.SaveChanges();
 }
 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);
             }
         }
     }
 }