public void BeforeAdd(object newState, IDataMutatorContext ctx) { newState.ThrowIfNull(nameof(newState)); ctx.ThrowIfNull(nameof(ctx)); var s = (IOwned)newState; s.OwnedBy = ctx.Identity.Name; }
public void BeforeAdd(object subject, IDataMutatorContext context) { subject.ThrowIfNull(nameof(subject)); context.ThrowIfNull(nameof(context)); var s = subject as ICreatedOn; s.CreatedOn = context.RequestedOn; }
public void BeforeModify(object oldState, object newState, IDataMutatorContext ctx) { newState.ThrowIfNull(nameof(newState)); ctx.ThrowIfNull(nameof(ctx)); var s = (IOwned)newState; s.UpdatedBy = ctx.Identity.Name; s.UpdatedOn = ctx.RequestedOn; }
public void BeforeRemove(object oldState, IDataMutatorContext ctx) { oldState.ThrowIfNull(nameof(oldState)); ctx.ThrowIfNull(nameof(ctx)); var s = (IOwned)oldState; s.RemovedBy = ctx.Identity.Name; s.RemovedOn = ctx.RequestedOn; }
public void BeforeAdd(object subject, IDataMutatorContext context) { subject.ThrowIfNull(nameof(subject)); context.ThrowIfNull(nameof(context)); if ((subject is BaseDataModel s) && (s.Id == Guid.Empty)) { s.Id = Guid.NewGuid(); } }
public bool CanHandle(IDataMutatorContext ctx) { if (ctx.Action != DataActions.Add) { return(false); } if (ctx.DataSubjectType.GetInterfaces().Contains(typeof(ICreatedOn)) == false) { return(false); } return(true); }
public bool CanHandle(IDataMutatorContext ctx) { if (ctx.Action != DataActions.Add) { return(false); } if (ctx.DataSubjectType != typeof(IOwned)) { return(false); } return(true); }
public void BeforeRemove(object oldState, IDataMutatorContext context) { }
public void BeforeModify(object oldState, object newState, IDataMutatorContext context) { }
public bool CanHandle(IDataMutatorContext ctx) { return(ctx.DataSubjectType == typeof(ProductDataModel)); }
public void BeforeRemove(object oldState, IDataMutatorContext context) { oldState.ThrowIfNull(nameof(oldState)); ExpireCache(oldState); }
public void BeforeAdd(object newState, IDataMutatorContext context) { newState.ThrowIfNull(nameof(newState)); ExpireCache(newState); }
private IEnumerable <IDataMutatorHandler> GetHandlers(IDataMutatorContext ctx) { return(_dataMutators.Where(x => x.CanHandle(ctx))); }