Beispiel #1
0
        public HttpResponseMessage Add(ReportComponentDto reportDto)
        {
            var handler  = new AddHandler();
            var response = handler.Handle(reportDto);

            if (handler.Errors == null || handler.Errors.Count < 1)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, response.ReportComponentDtos[0]));
            }
            return(Request.CreateResponse(HttpStatusCode.BadRequest, handler.Errors));
        }
Beispiel #2
0
        public ReportComponentDto ReportComponentToDto(ReportComponent report)
        {
            var dto = new ReportComponentDto
            {
                Id               = report.Id,
                Title            = report.Title,
                Type             = report.Type,
                ModificationDate = report.ModificationDate,
                Metrics          = MetricToDto(report.Data.Metrics),
                SubmissionDate   = report.CreationDate,
                Dimensions       = report.Data.Dimensions,
                Filters          = report.Data.Filters
            };

            return(dto);
        }
Beispiel #3
0
        public ReportComponent DtoToReportComponent(ReportComponentDto dto)
        {
            var report = new ReportComponent
            {
                Id               = dto.Id,
                Title            = dto.Title,
                CreationDate     = dto.SubmissionDate,
                Type             = dto.Type,
                ModificationDate = dto.ModificationDate,
                Data             = new ComponentData {
                    Dimensions = dto.Dimensions, Filters = dto.Filters, Metrics = DtoToMetric(dto.Metrics)
                }
            };

            return(report);
        }
Beispiel #4
0
        public void ShouldMapDtoToComponent()
        {
            //Arrange
            var mapping = new Mapping();
            var source  = new ReportComponentDto
            {
                Id         = 1,
                Title      = "Test",
                Type       = 1,
                Dimensions = new List <Dimension> {
                    new Dimension {
                        DimensionId = 1
                    }
                },
                Filters = new List <Filter> {
                    new Filter {
                        FilterId = 1
                    }
                },
                Metrics = new List <MetricDto> {
                    new MetricDto {
                        DataType = " ", Description = " ", DisplayName = " ", Group = new MetricGroup {
                            GroupId = 1, GroupName = " "
                        }, MetricId = 1, Mnemonic = " "
                    }
                },
                SubmissionDate = "now"
            };

            //Act
            ReportComponent destination = mapping.DtoToReportComponent(source);

            //Assert
            Assert.AreNotSame(source, destination);
            Assert.IsInstanceOfType(destination, typeof(ReportComponent));
            Assert.AreEqual(source.Title, destination.Title);
            Assert.AreEqual(source.Id, destination.Id);
            Assert.AreEqual(source.Type, destination.Type);
            Assert.AreEqual(source.Dimensions.Count, destination.Data.Dimensions.Count);
            Assert.AreEqual(source.Filters.Count, destination.Data.Filters.Count);
            Assert.AreEqual(source.Metrics.Count, destination.Data.Metrics.Count);
        }
Beispiel #5
0
        public void ShouldMapReportComponentToDto()
        {
            //Arrange
            var mapping = new Mapping();
            var source  = new ReportComponent
            {
                Id    = 1,
                Title = "Test",
                Type  = 1,
                Data  = new ComponentData
                {
                    Dimensions = new List <Dimension> {
                        new Dimension {
                            DimensionId = 1
                        }
                    },
                    Filters = new List <Filter> {
                        new Filter {
                            FilterId = 1
                        }
                    },
                    Metrics = new List <Metric> {
                        new Metric {
                            MetricId = 1
                        }
                    }
                }
            };

            //Act
            ReportComponentDto destination = mapping.ReportComponentToDto(source);

            //Assert
            Assert.AreNotSame(source, destination);
            Assert.IsInstanceOfType(destination, typeof(ReportComponentDto));
            Assert.AreEqual(source.Title, destination.Title);
            Assert.AreEqual(source.Id, destination.Id);
            Assert.AreEqual(source.Data.Metrics.Count, destination.Metrics.Count);
            Assert.AreEqual(source.Data.Filters.Count, destination.Filters.Count);
            Assert.AreEqual(source.Data.Dimensions.Count, destination.Dimensions.Count);
            Assert.AreEqual(source.Type, destination.Type);
        }
Beispiel #6
0
 public ReportComponentResponse(ReportComponentDto reportComponent)
 {
     ReportComponentDtos = new List <ReportComponentDto> {
         reportComponent
     };
 }