/// <summary> /// Creates a record based on the previous record created, passes in the entire object of the record that was created /// </summary> /// <typeparam name="TParent"></typeparam> /// <typeparam name="TEntity"></typeparam> /// <param name="app"></param> /// <returns></returns> public virtual IRecordService <TID> CreatedRelatedRecord <TParent, TEntity>(IRelatedRecordCreator <TParent, TEntity, TID> app) { Guard.AgainstNull(this.CreatedRecords); var res = app.CreateRecord((TParent)CreatedRecords.Last().Value); this.CreatedRecords.Add(res.Id, res.Row); return(this); }
/// <summary> /// Create a record based on the record that was previously created, passes in the ID of the Previous record that was created /// </summary> /// <typeparam name="TEntity"></typeparam> /// <param name="app"></param> /// <returns></returns> public virtual IRecordService <TID> CreateRelatedRecord <TEntity>(IRelatedRecordCreator <TEntity, TID> app) { if (this.CreatedRecords.Any()) { this.policy.Execute(() => { var res = app.CreateRecord(CreatedRecords.Last().Key); this.CreatedRecords.Add(res.Id, res.Row); }); } return(this); }
public IRecordService <TID> ExecuteAction(IExecutableAction <TID> implementation, bool executeAgainstAggregate = false) { this.policy.Execute(() => { if (executeAgainstAggregate) { implementation.Execute(AggregateId); } else { if (!CreatedRecords.Any()) { throw new ArgumentException("You must create records before executing an action against them"); } implementation.Execute(CreatedRecords.Last().Key); } }); return(this); }
public int GetRecordCount() { return(CreatedRecords.Count()); }
/// <summary> /// Execute Action against the id of the last created record /// </summary> /// <typeparam name="T"></typeparam> /// <param name="implementation"></param> /// <returns></returns> public IRecordService <TID> ExecuteAction <T>(IExecutableAction <T, TID> implementation) { implementation.Execute(CreatedRecords.Last().Key); return(this); }