Ejemplo n.º 1
0
        public static async Task <T> SetLoadedGet <T>(IEntityService service, IEntityException exceptionService,
                                                      EntitySubEntitiesGetDto dto, string function)
        {
            exceptionService.ThrowEntityNotFoundExceptionIfIdDoesNotExist(dto.Id);
            var date     = DateTimeParser.FromWebFormat(dto.Date);
            var entities = await service.GetAll(function, dto.Id, date).ToListAsync();

            dto.Entities = entities;

            return(AutoMapperConfig.MapperInstance.Map <T>(dto));
        }
Ejemplo n.º 2
0
        public static async Task <T> SetGet <T>(IEntityService service, IEntityException exceptionService,
                                                SubEntitiesGetDto dto, string function)
        {
            exceptionService.ThrowEntityNotFoundExceptionIfIdDoesNotExist(dto.Id);
            var date   = DateTimeParser.FromWebFormat(dto.Date);
            var values = await service.GetAll(function, dto.Id, date, 1).ToListAsync();

            var headers = await service.GetAll(function, dto.Id, date).FirstOrDefaultAsync();

            dto.Values           = values;
            dto.Headers          = headers;
            dto.HeadersSelection = headers;

            return(AutoMapperConfig.MapperInstance.Map <T>(dto));
        }
Ejemplo n.º 3
0
        public static async Task <T> SetGet <T>(int id, string date, IEntityDetailsService service, IEntityException exceptionService, QueriesToPassDto queryDto)
        {
            exceptionService.ThrowEntityNotFoundExceptionIfIdDoesNotExist(id);

            var dateParsed = DateTimeParser.FromWebFormat(date);
            var entity     = await service.GetByIdAndDate(queryDto.SqlFunctionById, id, dateParsed).ToListAsync();

            string   startConnectionString = entity.ToList()[1][IndexStartConnectionInSQLTable];
            string   endConnectionString   = entity.ToList()[1][IndexEndConnectionInSQLTable];
            DateTime?endConnection         = null;

            if (!string.IsNullOrWhiteSpace(endConnectionString) && endConnectionString != GlobalConstants.EmptyEndConnectionDisplay)
            {
                endConnection = DateTimeParser.FromSqlFormat(endConnectionString);
            }

            var dto = new SpecificEntityOverviewGetDto()
            {
                Id              = id,
                Date            = date,
                Entity          = entity,
                StartConnection = DateTimeParser.FromSqlFormat(startConnectionString),
                EndConnection   = endConnection,
            };

            if (queryDto.SqlFunctionContainer != null)
            {
                dto.Container = service.GetContainer(queryDto.SqlFunctionContainer, id, dateParsed);
            }

            if (queryDto.SqlFunctionActiveSE != null)
            {
                var subEntities = await service.GetSubEntities(queryDto.SqlFunctionActiveSE, id, dateParsed, 1).ToListAsync();

                dto.SubEntityCount = subEntities.Count;
            }

            return(AutoMapperConfig.MapperInstance.Map <T>(dto));
        }