Example #1
0
        public async Task CreateFailed()
        {
            MockListener.Reset();
            await Listen.CreateFailedAsync(ent, ctx);

            Assert.IsFalse(MockListener.WasOnCreatedCalled);
            Assert.IsTrue(MockListener.WasOnCreationValidationFailedCalled);
            Assert.IsFalse(MockListener.WasOnModifiedCalled);
            Assert.IsFalse(MockListener.WasOnModificationFailedCalled);
            Assert.IsFalse(MockListener.WasOnDeletedCalled);
            Assert.IsFalse(MockListener.WasOnDeletionFailedCalled);
        }
Example #2
0
        private async Task <AuthorizationResult> AuthorizeAddAsync(IIdentity usr, T newEntity)
        {
            var authResult = (await Authorize.CreateAsync(newEntity, GetContextInfo(usr))).CreateAggregateResult();

            if (!authResult.HasSucceed)
            {
                await Listen.CreateFailedAsync(newEntity, GetContextInfo(usr));

                _dbcontext.Entry(newEntity).State = EntityState.Detached;
            }

            return(authResult);
        }