private static void InsertTipologyValidation(ConfigurationContext dataContext, Tipology tipology, int formulaId) { var tbc = dataContext.Tipologies .Where(t => t.MacroType == tipology.MacroType && (t.TypeOne == tipology.TypeOne || tipology.TypeOne == null) && (t.TypeTwo == tipology.TypeTwo || tipology.TypeTwo == null) ) .ToList() .Select(t => new TipologyFormula { FormulaId = formulaId, TipologyId = t.Id } ); dataContext.TipologiesFormulas.InsertAllOnSubmit(tbc); dataContext.SubmitChanges(); }
private static void UpdateTipologyConfiguration(ConfigurationContext dataContext, Tipology tipology, int formulaId) { if (tipology.Id != null) { var dbTipology = dataContext.ConfTipologies.FirstOrDefault(t => t.Id == tipology.Id); // ReSharper disable once PossibleNullReferenceException dbTipology.MacroType = tipology.MacroType; dbTipology.TypeOne = tipology.TypeOne; dbTipology.TypeTwo = tipology.TypeTwo; dataContext.SubmitChanges(); } else { var dbTipology = tipology.MaptoDbConfTipology(); dataContext.ConfTipologies.InsertOnSubmit(dbTipology); dataContext.SubmitChanges(); dataContext.ConfTipologiesFormulas.InsertOnSubmit(new ConfTipologyFormula { FormulaId = formulaId, TipologyId = dbTipology.Id }); dataContext.SubmitChanges(); } }
private static void CreateTipologyValidation(ConfigurationContext dataContext, Tipology tipology, int formulaId) { InsertTipologyValidation(dataContext, tipology, formulaId); dataContext.SubmitChanges(); }