Exemplo n.º 1
0
        public BaseResponseDto AddEntities <T>(IEnumerable <T> entities, PaginationDto pagination = null)
            where T : EntityDto, new()
        {
            if (!Data.ContainsKey(typeof(T)))
            {
                Data[typeof(T)] = new ListDto
                {
                    PrimaryKey = typeof(T).GetEntityPrimaryKeyName(),
                    List       = new Dictionary <object, EntityDto>()
                };
            }

            var list = Data[typeof(T)].List;

            foreach (var entity in entities)
            {
                list[entity.GetEntityPrimaryKey()] = entity;
            }

            if (pagination != null)
            {
                Data[typeof(T)].Pagination = pagination;
            }

            return(this);
        }
Exemplo n.º 2
0
 public new T AddEntity <TEntity>(TEntity entity, PaginationDto pagination = null)
     where TEntity : EntityDto, new()
 {
     return(AddEntities(new List <TEntity> {
         entity
     }, pagination));
 }
Exemplo n.º 3
0
 public BaseResponseDto AddEntity <T>(T entity, PaginationDto pagination = null)
     where T : EntityDto, new()
 {
     return(AddEntities(new List <T> {
         entity
     }, pagination));
 }
Exemplo n.º 4
0
        public new T AddEntities <TEntity>(IEnumerable <TEntity> entities, PaginationDto pagination = null)
            where TEntity : EntityDto, new()
        {
            if (!EntityTypes.Contains(typeof(TEntity)))
            {
                throw new ArgumentException(
                          $"Entity type {typeof(TEntity).Name} is not supported by this response type.");
            }

            return((T)base.AddEntities(entities, pagination));
        }