示例#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));
        }
示例#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));
        }
示例#3
0
        public static async Task <T> SetGet <T>(int id, string date, IEntityDetailsService service, IEntityException exceptionService, QueriesToPassDto queryDto)
        {
            exceptionService.DoesExist(id);

            var dateParsed = DateTimeExtensions.FromWebFormat(date);
            var entity     = await service.ByIdAndDate(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 = DateTimeExtensions.FromSqlFormat(endConnectionString);
            }

            var dto = new DetailsDto()
            {
                Id              = id,
                Date            = date,
                Entity          = entity,
                StartConnection = DateTimeExtensions.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));
        }