Exemplo n.º 1
0
        private Indicator ParseForEdit(IndicatorDTO indicatorDTO)
        {
            if (indicatorDTO != null)
            {
                var indicator = unit.IndicatorRepository.Get(p => p.Id == indicatorDTO.Id).FirstOrDefault();
                if (indicator.Comment != indicatorDTO.Comment)
                {
                    indicator.Comment = indicatorDTO.Comment;
                }
                if (indicator.CriteriaId != indicatorDTO.CriteriaId)
                {
                    indicator.CriteriaId = indicatorDTO.CriteriaId;
                }
                if (indicator.Name != indicatorDTO.Name)
                {
                    indicator.Name = indicatorDTO.Name;
                }
                if (indicator.ScoreId != indicatorDTO.ScoreId && indicatorDTO.ScoreId != null)
                {
                    indicator.ScoreId = indicatorDTO.ScoreId;
                }
                if (indicator.Id != indicatorDTO.Id)
                {
                    indicator.Id = indicatorDTO.Id;
                }

                return(indicator);
            }
            else
            {
                throw new NotSupportedException(String.Format("BAD GATEWAY!!! {0} EDIT oparation temporary NOT SUPPORTED for Indicator table...", Environment.NewLine));
            }
        }
Exemplo n.º 2
0
        public void ParseIndicatorParameterNull_Test()
        {
            // Arrange
            IndicatorDTO indicatorDTO = null;

            // Act
            Indicator indicator = factory.Parse(indicatorDTO);
        }
Exemplo n.º 3
0
 public Indicator Parse(IndicatorDTO indicatorDTO)
 {
     if (indicatorDTO.Id != 0)
     {
         return(ParseForEdit(indicatorDTO));
     }
     else
     {
         return(ParseForAdd(indicatorDTO));
     }
 }
Exemplo n.º 4
0
        public void ParseIndicatorIdNotZero_Test()
        {
            // Arrange
            IndicatorDTO indicatorDTO = new IndicatorDTO
            {
                Id      = 2,
                Comment = "Comment",
                Name    = "Name",
            };

            // Act
            Indicator indicator = factory.Parse(indicatorDTO);

            // Assert
            Assert.True(indicator != null &&
                        indicator.Id == indicatorDTO.Id &&
                        indicator.Comment == indicatorDTO.Comment &&
                        indicator.Name == indicatorDTO.Name);
        }
Exemplo n.º 5
0
        private Indicator ParseForAdd(IndicatorDTO indicatorDTO)
        {
            if (indicatorDTO != null)
            {
                var indicator = new Indicator()
                {
                    Name       = indicatorDTO.Name,
                    Id         = indicatorDTO.Id,
                    Comment    = indicatorDTO.Comment,
                    ScoreId    = indicatorDTO.ScoreId,
                    CriteriaId = indicatorDTO.CriteriaId
                };

                return(indicator);
            }
            else
            {
                throw new NotSupportedException(String.Format("BAD GATEWAY {0} ADD operation temporaty NOT SUPPORTED for Indicator table", Environment.NewLine));
            }
        }