コード例 #1
0
        public async Task <Like> LikePhoto(string photoId, string albumId, User requestor)
        {
            if (!await _permissionsService.CanLike(requestor, albumId))
            {
                return(null);
            }
            var photo = await _photoService.GetPhoto(photoId);

            var like = new Like
            {
                ReactionId   = _guid.NewGuid().ToString(),
                Reactor      = requestor,
                ReactionDate = _clock.UtcNow
            };
            var photoLike = new PhotoLike
            {
                Photo = photo,
                Like  = like
            };

            photo.PhotoLikes.Add(photoLike);
            await _unitOfWork.Photos.Update(photo);

            return(like);
        }