public async Task <IActionResult> GetPhotoDetails(Guid photoId) { logger.LogInformation($"{nameof(GetPhotoDetails)}({nameof(photoId)} = '{photoId}')"); PhotoModel photo = await photosService.GetPhoto(photoId, GetCurrentUserId()); return(Json(photoModelConverter.ToPublic(photo))); }
public async Task <IActionResult> GetPhoto(int id) { var photoFromRepo = await _photosService.GetPhoto(id); var photo = _photosService.MapPhotoForReturn(photoFromRepo); return(Ok(photo)); }
public async Task <IActionResult> GetPhoto(int id) { var photoFromRepo = await _photoService.GetPhoto(id); if (photoFromRepo == null) { return(NotFound("Photo Not Found!")); } return(Ok(photoFromRepo)); }
private void CachePhotos(IList <PhotoDto> photos) { foreach (var id in photos.Take(10).Select(x => x.Id)) { _photosService.GetPhoto(Priority.Speculative, id); } }
private static async Task UpdatePhotoData(IPhotosService photoService, PhotoId photoId, IEnumerable <Size> imageSizes) { var photoFromDb = await photoService.GetPhoto(photoId, Guid.Empty); photoFromDb.State = PhotoState.PhotoAvailable; photoFromDb.Sizes = imageSizes; await photoService.UpdatePhoto(photoFromDb); }
public async Task <IActionResult> GetPhoto(int photoId) { var photo = await _service.GetPhoto(photoId); if (photo is null) { return(NotFound($"Could not find the photo '{photoId}'.")); } return(Ok(_mapper.To <PhotoToReturnDto>(photo))); }
public async Task <IActionResult> PhotoDetails(Guid photoId) { logger.LogInformation($"{nameof(PhotoDetails)}({nameof(photoId)} = '{photoId}')"); var userId = GetCurrentUserId(); PhotoModel photo = await photosService.GetPhoto(photoId, userId); if (photo == null) { return(NotFound()); } bool photoIsOwnedByCurrentUser = userId == photo.UserId; logger.LogInformation($"{nameof(userId)} = '{userId}', {nameof(photo.UserId)} = '{photo.UserId}'. Photo {(photoIsOwnedByCurrentUser ? "is" : "is NOT")} owned by current user."); // If the state is not PhotoAvailable, show it only if it's owned by the current user if (photo.State != PhotoState.PhotoAvailable && !photoIsOwnedByCurrentUser) { return(NotFound()); } return(base.View(photoModelConverter.ToPublic(photo, userId.Equals(Guid.Empty) ? null : (Guid?)userId))); }
public async Task <IActionResult> GetPhoto(int id) { return(Ok(await _photosService.GetPhoto(id))); }