示例#1
0
        public JsonResult AddLike(Guid imageId)
        {
            var like = new Like
            {
                Id      = Guid.NewGuid().ToString(),
                ImageId = imageId.ToString(),
                DocType = "Like"
            };

            _likeRepository.CreateItemAsync(like).GetAwaiter();
            var images = _imageRepository.GetItemsAsync(x => x.DocType == "Image" && x.ImageId == imageId.ToString())
                         .GetAwaiter().GetResult();
            var image = images.FirstOrDefault();

            image.Likes++;
            _imageRepository.UpdateItemAsync(image.Id, image).GetAwaiter();
            return(Json(new { Message = string.Empty }));
        }