Exemplo n.º 1
0
        public void UpdateDisplayProperties(PhotoDisplayPropertiesDetailModel model)
        {
            Guard.NotNull(model, nameof(model), Constants.NullExceptionGenerator);

            _logger.LogInformation($"updating photo with display properties: {JsonConvert.SerializeObject(model)}");

            ValidatePhotoExists(model.PhotoId);
            ValidatePhotoGroupExists(model.PhotoGroupId);
            var entity = Mapper.Map <PhotoDisplayProperties>(model);

            _photoRepository.UpdateDisplayProperties(model.PhotoId, entity);
        }
Exemplo n.º 2
0
        public void UpdatePhotoGroupDoesntExistThrowsTest()
        {
            var manager = GetManager();
            var model   = new PhotoDisplayPropertiesDetailModel();

            _photoRepositoryMock
            .Setup(x => x.Exists(It.IsAny <int>()))
            .Returns(true);

            _photoGroupRepositoryMock
            .Setup(x => x.Exists(It.IsAny <int>()))
            .Returns(false);

            Assert.Throws <BusinessException>(() => manager.UpdateDisplayProperties(model));
        }
Exemplo n.º 3
0
        public void UpdateModelPassedToRepositoryTest()
        {
            var manager = GetManager();
            var model   = new PhotoDisplayPropertiesDetailModel();

            _photoRepositoryMock
            .Setup(x => x.Exists(It.IsAny <int>()))
            .Returns(true);
            _photoGroupRepositoryMock
            .Setup(x => x.Exists(It.IsAny <int>()))
            .Returns(true);

            manager.UpdateDisplayProperties(model);

            _photoRepositoryMock.Verify(
                x => x.UpdateDisplayProperties(It.IsAny <int>(), It.Is <PhotoDisplayProperties>(y => y != null)),
                Times.Once);
        }
Exemplo n.º 4
0
        public void PhotoDisplayPropertiesDetailModelMapToPhotoTest()
        {
            var model = new PhotoDisplayPropertiesDetailModel
            {
                PhotoId      = 1,
                Title        = Guid.NewGuid().ToString(),
                PhotoGroupId = 2,
                SortOrder    = 3
            };

            var entity = Mapper.Map <Photo>(model);

            Assert.Null(entity.Data);
            Assert.Equal(model.PhotoId, entity.Id);
            Assert.Equal(model.Title, entity.DisplayProperties.Title);
            Assert.Equal(model.PhotoGroupId, entity.DisplayProperties.PhotoGroupId);
            Assert.Equal(model.SortOrder, entity.DisplayProperties.SortOrder);
        }
Exemplo n.º 5
0
 public ActionResult Update([FromBody] PhotoDisplayPropertiesDetailModel model)
 {
     _photoManager.UpdateDisplayProperties(model);
     return(Ok());
 }