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); }
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)); }
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); }
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); }
public ActionResult Update([FromBody] PhotoDisplayPropertiesDetailModel model) { _photoManager.UpdateDisplayProperties(model); return(Ok()); }