Example #1
0
        public List <DTOSize> ValidateSizes(ICollection <DTOSize> sizes, out string error)
        {
            var result = new List <DTOSize>();

            error = null;
            foreach (var size in sizes)
            {
                if (size.Position.Id != this.Id)
                {
                    error += Texts.Instance.SizeCorrespondsToAnotherPosition(size.Name) + " /n";
                    continue;
                }
                if (Size.DoesSizeExist(size, result, out string existError))
                {
                    error += existError + " /n";
                    continue;
                }
                if (Size.DoesSizeNameExist(size, result, out existError))
                {
                    error += existError + " /n";
                    continue;
                }
                result.Add(size);
            }
            return(result);
        }
Example #2
0
        public void DoesSizeNameExist_DTOList()
        {
            var size1 = new DTOSize(1, "1", new Money(1), new DTO.Position(1, "1", "1"));
            var size2 = new DTOSize(2, "2", new Money(1), new DTO.Position(1, "1", "1"));
            var size3 = new DTOSize(1, "2", new Money(1), new DTO.Position(1, "1", "1"));
            var sizes = new List <DTOSize>()
            {
                size1, size2
            };
            var result = Size.DoesSizeNameExist(size3, sizes, out var error);

            Assert.IsTrue(result);
            Assert.AreEqual($"Name {size3.Name} is already taken", error);
        }