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