/// <summary> /// please sure call obj.BuildMetaData() before call this. /// </summary> /// <param name="provider"></param> /// <param name="obj"></param> /// <returns></returns> protected async Task <T> CommitAsync(IObjectEditProvider <T> provider, T obj) { if (obj.HasError()) { if (Debugger.IsAttached) { Debugger.Break(); } return(null); } switch (this.Action) { case ObjectChangedAction.Create: obj.ResetCreated(); var arg = new RequestActionEventArgs <T>(obj) { IsAccept = true }; this.Creating.Fire(this, arg); if (arg.IsAccept && await provider.InsertAsync(obj)) { this.Clear(); this.Created.BeginFire(this, obj); return(obj); } else { return(null); } case ObjectChangedAction.Modify: if (await this.OnUpdateAsync(provider, obj)) { this.Updated.BeginFire(this, obj); return(obj); } else { return(null); } default: throw new ArgumentOutOfRangeException(); } }
protected virtual async Task <bool> OnUpdateAsync(IObjectEditProvider <T> provider, T obj) => await provider.UpdateAsync(obj);
public Task ExecuteAsync(IJasilyEntitySetReader<Model.JryVideo, string> reader, IObjectEditProvider<Model.JryVideo> provider) => this.CreateVersionAsync(reader, provider);
public Task ExecuteAsync(IJasilyEntitySetReader<JryFlag, string> reader, IObjectEditProvider<JryFlag> provider) => this.CreateVersionAsync(reader, provider);
public Task ExecuteAsync(IJasilyEntitySetReader<VideoRoleCollection, string> reader, IObjectEditProvider<VideoRoleCollection> provider) => this.CreateVersionAsync(reader, provider);
private async Task CreateVersionAsync<T>(IJasilyEntitySetReader<T, string> reader, IObjectEditProvider<T> provider) where T : class, IObject { await ((MongoEntitySet<T>)reader).NotExistsFieldCursorAsync(nameof(IObject.Version), async z => await provider.UpdateAsync(z)); }
protected override async Task <bool> OnUpdateAsync(IObjectEditProvider <JryFlag> provider, JryFlag obj) => await((FlagManager)provider).UpdateNameAsync(obj.Type, this.OldValue, obj.Value);
public SubObjectSetProvider(IObjectEditProvider <T> parentManager, T parent) { this.parentManager = parentManager; this.Parent = parent; }