12345678910111213141516171819202122232425262728 |
- using Comal.Classes;
- using InABox.Core;
- namespace Comal.Stores;
- internal class TaxCodeStore : BaseStore<TaxCode>
- {
- protected override void BeforeSave(TaxCode entity)
- {
- base.BeforeSave(entity);
- var otherrows = Provider.Query(new Filter<TaxCode>(x => x.Default).IsEqualTo(true));
- if (entity.Default)
- {
- if (otherrows.Rows.Any())
- {
- var others = otherrows.Rows.Select(x => x.ToObject<TaxCode>()).ToArray();
- foreach (var other in others)
- other.Default = false;
- Provider.Save(others);
- }
- }
- else
- {
- if (!otherrows.Rows.Any())
- entity.Default = true;
- }
- }
- }
|