Esempio n. 1
0
        public async Task <IDataResult <T> > ProcessUpdate(IDataChangeSet <T> changeSet)
        {
            IDataValidationStrategy <T> validator = CreateValidator();

            using (TransactionScope(changeSet.Instance))
            {
                if (await IsAccessForUpdate(changeSet.Instance))
                {
                    IDataResult <T> result = validator.Validate(changeSet);

                    if (result.Ok)
                    {
                        await ApplyUpdate(changeSet);
                        await UpdateComplete(changeSet);
                    }

                    return(result);
                }

                return(validator.Context.CriticalError(changeSet.Instance, "PermissionDenied"));
            }
        }
Esempio n. 2
0
        public async Task <IDataResult <T> > ProcessInsert(T instance)
        {
            IDataValidationStrategy <T> validator = CreateValidator();


            using (TransactionScope(instance))
            {
                if (await IsAccessForInsert(instance))
                {
                    IDataResult <T> result = validator.Validate(new ObjectChangeSet <T>(instance));

                    if (result.Ok)
                    {
                        await RunInsert(instance);
                        await InsertComplete(instance);
                    }

                    return(result);
                }
                return(validator.Context.CriticalError(instance, "PermissionDenied"));
            }
        }