コード例 #1
0
        public override async Task <I> InsertAsync(I entity)
        {
            entity.CheckArgument(nameof(entity));
            entity.ConnectorItem.CheckArgument(nameof(entity.ConnectorItem));
            entity.OneItem.CheckArgument(nameof(entity.OneItem));
            entity.AnotherItem.CheckArgument(nameof(entity.AnotherItem));

            var result = new E();

            result.OneEntity.CopyProperties(entity.OneItem);
            if (entity.OneItemIncludeSave)
            {
                if (result.OneEntity.Id == 0)
                {
                    await OneEntityController.InsertAsync(result.OneEntity).ConfigureAwait(false);

                    var piNav = GetNavigationToOne();

                    if (piNav != null)
                    {
                        piNav.SetValue(result.ConnectorEntity, result.OneEntity);
                    }
                }
                else
                {
                    await OneEntityController.UpdateAsync(result.OneEntity).ConfigureAwait(false);
                }
            }

            result.AnotherEntity.CopyProperties(entity.AnotherItem);
            if (entity.AnotherItemIncludeSave)
            {
                if (result.AnotherItem.Id == 0)
                {
                    await AnotherEntityController.InsertAsync(result.AnotherEntity).ConfigureAwait(false);

                    var piNav = GetNavigationToAnother();

                    if (piNav != null)
                    {
                        piNav.SetValue(result.ConnectorEntity, result.AnotherEntity);
                    }
                }
                else
                {
                    await AnotherEntityController.UpdateAsync(result.AnotherEntity).ConfigureAwait(false);
                }
            }
            result.ConnectorEntity.CopyProperties(entity.ConnectorItem);
            await ConnectorEntityController.InsertAsync(result.ConnectorEntity).ConfigureAwait(false);

            return(await BeforeReturnAsync(result).ConfigureAwait(false));
        }
コード例 #2
0
        public override async Task DeleteAsync(int id)
        {
            var entity = await GetByIdAsync(id).ConfigureAwait(false);

            if (entity != null)
            {
                await ConnectorEntityController.DeleteAsync(entity.Id).ConfigureAwait(false);
            }
            else
            {
                throw new LogicException(ErrorType.InvalidId);
            }
        }
コード例 #3
0
        public override async Task <IEnumerable <I> > QueryAllAsync(string predicate)
        {
            var result = new List <E>();
            var query  = await ConnectorEntityController.QueryAllAsync(predicate).ConfigureAwait(false);

            foreach (var item in query)
            {
                E entity = new E();

                entity.ConnectorEntity.CopyProperties(item);
                await LoadChildsAsync(entity).ConfigureAwait(false);

                result.Add(entity);
            }
            return(await BeforeReturnAsync(result).ConfigureAwait(false));
        }
コード例 #4
0
        public override async Task <IEnumerable <I> > GetPageListAsync(int pageIndex, int pageSize)
        {
            var result = new List <E>();
            var query  = await ConnectorEntityController.GetPageListAsync(pageIndex, pageSize).ConfigureAwait(false);

            foreach (var item in query)
            {
                E entity = new E();

                entity.ConnectorEntity.CopyProperties(item);
                await LoadChildsAsync(entity).ConfigureAwait(false);

                result.Add(entity);
            }
            return(await BeforeReturnAsync(result).ConfigureAwait(false));
        }
コード例 #5
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                ChangedSessionToken -= HandleChangedSessionToken;

                ConnectorEntityController.Dispose();
                OneEntityController.Dispose();
                AnotherEntityController.Dispose();

                ConnectorEntityController = null;
                OneEntityController       = null;
                AnotherEntityController   = null;
            }
        }
コード例 #6
0
        public override async Task <I> GetByIdAsync(int id)
        {
            E   result;
            var entity = await ConnectorEntityController.GetByIdAsync(id).ConfigureAwait(false);

            if (entity != null)
            {
                result = new E();
                result.ConnectorEntity.CopyProperties(entity);
                await LoadChildsAsync(result).ConfigureAwait(false);
            }
            else
            {
                throw new LogicException(ErrorType.InvalidId);
            }
            return(await BeforeReturnAsync(result).ConfigureAwait(false));
        }