示例#1
0
        public async Task <IActionResult> Like([FromBody] ImageLike like)
        {
            var hasAny = await _imageRepository.QueryLikes()
                         .AnyAsync(a => a.ImageId == like.ImageId &&
                                   a.UserId == like.UserId);

            if (hasAny)
            {
                return(Ok(new ResponseDto()
                {
                    Message = "content liked already",
                    Status = ResponseStatus.Success
                }));
            }

            await _imageRepository.AddImageLike(like);

            await _imageRepository.Save();

            return(Ok(
                       new ResponseDto()
            {
                Status = ResponseStatus.Success,
                Data = like
            }));
        }