public async Task <IActionResult> Latest() { logger.LogInformation($"{nameof(Latest)}()"); IEnumerable <PhotoModel> latestPhotos = await photosService.GetLatestPhotos(GetCurrentUserId()); UserId userId = GetCurrentUserId(); return(View(latestPhotos.Select(x => photoModelConverter.ToPublic(x, userId.Equals(Guid.Empty) ? null : (Guid?)userId)))); }
public async Task <IActionResult> CreatePhoto([FromBody] CreatePhotoModel input) { logger.LogInformation($"{nameof(CreatePhoto)}({nameof(input.Filename)} = '{input.Filename}')"); try { var photo = await photosService.CreatePhoto(GetCurrentUserId(), GetCurrentUserName(), input.Filename, input.Text); return(Json(photoModelConverter.ToPublic(photo))); } catch (Exception ex) { logger.LogError(ex, $"Error in {nameof(CreatePhoto)}({nameof(input.Filename)} = '{input.Filename}'):\n{ex.ToString()}"); throw; } }
public void ToPublic_HashTag() { var converter = new PhotoModelConverter(imageAssetHost, new TextSplitter(new HttpHelper(), logWriterFactoryMock.Object), logWriterFactoryMock.Object); var publicPhoto = converter.ToPublic(GetPhotoModelWithGivenText(TextWithHashTag)); publicPhoto.HtmlText.ShouldBe("This is a regular text with a <a href=\"/tags/hashtag\">#hashtag</a> embedded."); }
public void ToPublic_RegularText() { var converter = new PhotoModelConverter(imageAssetHost, new TextSplitter(new HttpHelper(), logWriterFactoryMock.Object), logWriterFactoryMock.Object); var publicPhoto = converter.ToPublic(GetPhotoModelWithGivenText(RegularTextWithNoSpecialFeatures)); publicPhoto.Text.ShouldBe(RegularTextWithNoSpecialFeatures); }