Пример #1
0
        public void LinkImageToClothingItem(Guid imageId, Guid clothingItemId)
        {
            var link = new ClothingItemImage();

            link.ClothingItemId = clothingItemId;
            link.ImageId        = imageId;

            _context.ClothingItemImages.Add(link);
            _context.SaveChanges();
        }
Пример #2
0
        public void ClothingItemImageValidatorTests_CorrectInput_IsValid()
        {
            var testEntity = new ClothingItemImage();

            testEntity.ClothingItemId = Guid.NewGuid();
            testEntity.ImageId        = Guid.NewGuid();

            var result = testEntity.Validate();

            Assert.AreEqual(true, result.IsValid());
        }
Пример #3
0
        public void ClothingItemImageValidatorTests_InvalidInput_ContainsErrors()
        {
            var testEntity = new ClothingItemImage();

            var result = testEntity.Validate() as DictionaryValidationResult;

            Assert.AreEqual(false, result.IsValid());
            Assert.AreEqual(true, result.ContainsKey(V.ClothingItemImage_ClothingItemId));
            Assert.AreEqual(true, result.ContainsKey(V.ClothingItemImage_ImageId));

            Console.WriteLine(result.GetValidationResult());
        }
        public static IValidationResult Validate(this ClothingItemImage clothingItemImage)
        {
            var result = new DictionaryValidationResult();

            if (clothingItemImage.ClothingItemId == Guid.Empty)
            {
                result.AddError(V.ClothingItemImage_ClothingItemId, V.ClothingItemImage_ClothingItemId_Empty);
            }

            if (clothingItemImage.ImageId == Guid.Empty)
            {
                result.AddError(V.ClothingItemImage_ImageId, V.ClothingItemImage_ImageId_Empty);
            }

            return(result);
        }