Beispiel #1
0
        private static bool LikeProfilePhotos(List <Photo> profilePhotos, VkApi api, UserExtended user)
        {
            var result = false;

            var likedPhotosCounter = 0;

            foreach (var profilePhoto in profilePhotos)
            {
                if (profilePhoto.Likes.UserLikes)
                {
                    continue;
                }

                if (profilePhoto.Id.HasValue)
                {
                    result = _likesService.AddLike(user.Id, profilePhoto.Id.Value, LikeObjectType.Photo,
                                                   api);
                    likedPhotosCounter++;
                }

                if (likedPhotosCounter >= _profilePhotosToLike)
                {
                    break;
                }
            }

            return(result);
        }
Beispiel #2
0
        public async Task <IActionResult> LikeImage([FromForm] string id)
        {
            var userId = this.GetUserId();
            await _likesService.AddLike(id, userId);

            return(NoContent());
        }
Beispiel #3
0
        public IActionResult Like(Guid id)
        {
            if (_signInManager.IsSignedIn(User))
            {
                var item   = _productService.GetByID(id);
                var UserId = _userManager.GetUserId(User);

                if (!_likesServices.CheckUserId(item, UserId))
                {
                    _likesServices.AddLike(item);
                    _likesServices.AddUserIdToProducts(item, UserId);
                    return(RedirectToAction("Index", new { id }));
                }
            }
            return(RedirectToAction("Index", new { id }));
        }
        public ActionResult AddLike(AddLikeDto like)
        {
            try
            {
                _likesService.AddLike(like);
            }
            catch (FlowException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception)
            {
                return(StatusCode(500, "An error has occured!Try again later!"));
            }

            return(CreatedAtAction("AddLike", like));
        }
Beispiel #5
0
 public async Task <IHttpActionResult> AddLike(NewLikeModel model)
 {
     return(Ok(await service.AddLike(model)));
 }
Beispiel #6
0
        public async Task <IActionResult> AddUserLike([FromBody] LikeForAddDto likeDto)
        {
            await _service.AddLike(base.GetUserIdFromToken(), likeDto.ReceiverId);

            return(NoContent());
        }