| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | 
							- using Comal.Classes;
 
- using InABox.Core;
 
- namespace Comal.Stores;
 
- internal class JobScopeStatusStore : BaseStore<JobScopeStatus>
 
- {
 
-     protected override void BeforeSave(JobScopeStatus entity)
 
-     {
 
-         base.BeforeSave(entity);
 
-         var others = Provider.Query(new Filter<JobScopeStatus>(x => x.ID).IsNotEqualTo(entity.ID)
 
-             .And(new Filter<JobScopeStatus>(x=>x.ContractDefault).IsEqualTo(true)
 
-                 .Or(x=>x.VariationDefault).IsEqualTo(true)
 
-                 .Or(x=>x.AdjustmentDefault).IsEqualTo(true)
 
-             )
 
-         ).ToObjects<JobScopeStatus>().ToList();
 
-         
 
-         var otherContracts = others.Where(x=>x.ContractDefault);
 
-         if (entity.ContractDefault)
 
-         {
 
-             foreach (var otherContract in otherContracts)
 
-                 otherContract.ContractDefault = false;
 
-         }
 
-         else if (!otherContracts.Any())
 
-             entity.ContractDefault = true;
 
-         
 
-         var otherVariations = others.Where(x=>x.VariationDefault);
 
-         if (entity.VariationDefault)
 
-         {
 
-             foreach (var otherVariation in otherVariations)
 
-                 otherVariation.VariationDefault = false;
 
-         }
 
-         else if (!otherVariations.Any())
 
-             entity.VariationDefault = true;
 
-         
 
-         var otherAdjustments = others.Where(x=>x.AdjustmentDefault);
 
-         if (entity.AdjustmentDefault)
 
-         {
 
-             foreach (var otherAdjustment in otherAdjustments)
 
-                 otherAdjustment.AdjustmentDefault = false;
 
-         }
 
-         else if (!otherAdjustments.Any())
 
-             entity.AdjustmentDefault = true;
 
-         
 
-         Provider.Save(others.Where(x=>x.IsChanged()));
 
-     }
 
- }
 
 
  |