Esempio n. 1
0
        public async Task <Photo> StorePhoto(byte[] image, User author, string albumId)
        {
            if (!await _permissionsService.CanAddPicture(author, albumId))
            {
                return(null);
            }
            var id    = _guid.NewGuid().ToString();
            var photo = new Photo
            {
                Author        = author,
                PhotoComments = new List <PhotoComment>(),
                PhotoLikes    = new List <PhotoLike>(),
                Link          = $"{author.LastName}/{author.FirstName}/{id}",
                PhotoId       = id,
                TakeDate      = _clock.UtcNow
            };
            var album = await _albumService.GetAlbum(albumId);

            album.Photos.Add(photo);
            await _unitOfWork.Albums.Update(album);

            await _ftpService.StorePhotoOnFtp(image, photo);

            return(photo);
        }