Beispiel #1
0
        public async Task <Photo> UpdateAsync(int id, string title, byte[] photoFile, string imageMimeType, string description, string tokenValue)
        {
            Photo oldPhoto = await _photosRepository.FindAsync(id);

            oldPhoto.Title         = title;
            oldPhoto.PhotoFile     = photoFile;
            oldPhoto.ImageMimeType = imageMimeType;
            oldPhoto.Description   = description;
            oldPhoto.CreatedDate   = DateTime.Now;
            return(await _photosRepository.UpdateAsync(oldPhoto, tokenValue));
        }
Beispiel #2
0
        public async Task <Photo> UpdateAsync(int id, string title, byte[] photoFile, string imageMimeType, string description)
        {
            _logger.LogInformation("UpdateAsync called", id);
            Photo oldPhoto = await _photosRepository.FindAsync(id);

            oldPhoto.Title         = title;
            oldPhoto.PhotoFile     = photoFile;
            oldPhoto.ImageMimeType = imageMimeType;
            oldPhoto.Description   = description;
            oldPhoto.CreatedDate   = DateTime.Now;
            return(await _photosRepository.UpdateAsync(oldPhoto));
        }
        public async Task <Photo> UpdateAsync(Photo photo)
        {
            var user = await userService.GetUserAsync();

            if (await photosAuthorizationService.ItemMayBeUpdatedAsync(user, photo))
            {
                return(await repository.UpdateAsync(photo));
            }
            else
            {
                throw new UnauthorizedEditAttemptException <Photo>($"Unauthorized Edit Attempt of Photo {photo.Id}");
            }
        }