/// <inheritdoc />
        public virtual bool Update(TEntity entity)
        {
            if (NextLayer == null)
            {
                throw NewException($"Default implementation of {ResourceName}->{MethodBase.GetCurrentMethod().Name} in <{GetType().FriendlyName()}> can not pass through because {nameof(NextLayer)} is null.");
            }

            return(NextLayer.Update(entity));
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public virtual bool Update(TEntity entity)
        {
            if (NextLayer == null)
            {
                throw NewException($"Adapter from {typeof(TEntity).FriendlyName()} to {typeof(TNextEntity).FriendlyName()} for {ResourceName}->{MethodBase.GetCurrentMethod().Name} in <{GetType().FriendlyName()}> can not pass through because {nameof(NextLayer)} is null.");
            }

            try
            { return(NextLayer.Update(DataMapper.Convert <TEntity, TNextEntity>(entity))); }
            catch (OcDataMappingException ex)
            { throw NewException($"Error mapping data from {typeof(TEntity).FriendlyName()} to {typeof(TNextEntity).FriendlyName()}", ex, typeof(TEntity), typeof(TNextEntity)); }
        }
        /// <inheritdoc />
        public virtual bool Update(TEntity entity)
        {
            if (NextLayer == null)
            {
                throw NewException($"Default implementation of {ResourceName}->{MethodBase.GetCurrentMethod().Name} in <{GetType().FriendlyName()}> can not pass through because {nameof(NextLayer)} is null.");
            }
            if (HasErrors)
            {
                return(false);
            }

            // Apply logic & execute operation
            if (entity != null && ApplyLogic(entity, OcDataOperationType.Update))
            {
                return(NextLayer.Update(entity));
            }

            return(false);
        }