Exemplo n.º 1
0
        public void BeforeAdd(object newState, IDataMutatorContext ctx)
        {
            newState.ThrowIfNull(nameof(newState));
            ctx.ThrowIfNull(nameof(ctx));

            var s = (IOwned)newState;

            s.OwnedBy = ctx.Identity.Name;
        }
Exemplo n.º 2
0
        public void BeforeAdd(object subject, IDataMutatorContext context)
        {
            subject.ThrowIfNull(nameof(subject));
            context.ThrowIfNull(nameof(context));

            var s = subject as ICreatedOn;

            s.CreatedOn = context.RequestedOn;
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        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();
            }
        }
Exemplo n.º 6
0
 public bool CanHandle(IDataMutatorContext ctx)
 {
     if (ctx.Action != DataActions.Add)
     {
         return(false);
     }
     if (ctx.DataSubjectType.GetInterfaces().Contains(typeof(ICreatedOn)) == false)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 7
0
 public bool CanHandle(IDataMutatorContext ctx)
 {
     if (ctx.Action != DataActions.Add)
     {
         return(false);
     }
     if (ctx.DataSubjectType != typeof(IOwned))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 8
0
 public void BeforeRemove(object oldState, IDataMutatorContext context)
 {
 }
Exemplo n.º 9
0
 public void BeforeModify(object oldState, object newState, IDataMutatorContext context)
 {
 }
Exemplo n.º 10
0
 public bool CanHandle(IDataMutatorContext ctx)
 {
     return(ctx.DataSubjectType == typeof(ProductDataModel));
 }
Exemplo n.º 11
0
 public void BeforeRemove(object oldState, IDataMutatorContext context)
 {
     oldState.ThrowIfNull(nameof(oldState));
     ExpireCache(oldState);
 }
Exemplo n.º 12
0
 public void BeforeAdd(object newState, IDataMutatorContext context)
 {
     newState.ThrowIfNull(nameof(newState));
     ExpireCache(newState);
 }
Exemplo n.º 13
0
 private IEnumerable <IDataMutatorHandler> GetHandlers(IDataMutatorContext ctx)
 {
     return(_dataMutators.Where(x => x.CanHandle(ctx)));
 }