protected void overrideViewJobProdOpts(EditPrdnJobViewModel viewJob) { if ((viewJob.NotNullAny(j => j.ProdOptions)) && (viewJob.NotNullAny(j => j.IfNotNull(x => x.EditWorksheet).IfNotNull(e => e.WorksheetOpts)))) { foreach (var wOpt in viewJob.EditWorksheet.WorksheetOpts) { foreach (var pOpt in viewJob.ProdOptions.Where(o => !o.Overriden && o.OverrideMatch(wOpt))) { pOpt.Overriden = true; } } }; }
protected void UpdateJobWorksheet(ProductionJob editJob, EditPrdnJobViewModel viewJob) { bool anyWSRows = viewJob.NotNullAny(n => n.IfNotNull(x => x.EditWorksheet).IfNotNull(x => x.WorksheetOpts)); Worksheet worksheet = editJob.Worksheet; if (worksheet != null) // clear the existing worksheet chars and comps { PrdnDBContext.ExecuteStoreCommand("DELETE FROM FG_WORKSHEET_CHAR WHERE FG_WORKSHEET_ID = :p0", worksheet.ID); PrdnDBContext.ExecuteStoreCommand("DELETE FROM FG_WORKSHEET_COMP WHERE FG_PARENT_COMP_PROD_CD IS NOT NULL AND FG_WORKSHEET_ID = :p0", worksheet.ID); PrdnDBContext.ExecuteStoreCommand("DELETE FROM FG_WORKSHEET_COMP WHERE FG_WORKSHEET_ID = :p0", worksheet.ID); if (anyWSRows) { editJob.AssignWorksheet(worksheet); } else { PrdnDBContext.DeleteObject(worksheet); } } else if (anyWSRows) { worksheet = new Worksheet { ID = PrdnIsisEntities.GetNextWorksheetID() }; editJob.AssignWorksheet(worksheet); } if (anyWSRows) { viewJob.EditWorksheet.WorksheetOpts.ForEach(o => o.AssignTypeProps()); foreach (var opt in viewJob.EditWorksheet.WorksheetOpts.Where(o => (o.Type == OptionType.Component) && o.IsRoot)) { WorksheetComp comp = Mapper.Map<WorksheetOpt, WorksheetComp>(opt); worksheet.WorksheetComps.Add(comp); } foreach (var opt in viewJob.EditWorksheet.WorksheetOpts.Where(o => (o.Type == OptionType.Component) && !o.IsRoot)) { WorksheetComp comp = Mapper.Map<WorksheetOpt, WorksheetComp>(opt); worksheet.WorksheetComps.Add(comp); } foreach (var opt in viewJob.EditWorksheet.WorksheetOpts.Where(o => o.Type == OptionType.Characteristic)) { WorksheetChar chr = Mapper.Map<WorksheetOpt, WorksheetChar>(opt); worksheet.WorksheetChars.Add(chr); } } }