public IActionResult Like(int id)
        {
            if (Autentification.GetLoggedUser(HttpContext) != null)
            {
                Clients c    = clientRepository.GetClientByUserId(Autentification.GetLoggedUser(HttpContext).Id);
                Likes   like = new Likes();
                like.ArtworkId = id;
                like.ClientId  = c.Id;

                likesRepository.InsertLike(like);
                likesRepository.Save();
                return(RedirectToAction("Index", "Artwork"));
            }
            else
            {
                return(RedirectToAction("Index", "Autentification"));
            }
        }
Ejemplo n.º 2
0
        public ApiLike Like(Guid userId, Guid patternId)
        {
            var apiLike = likesRepository.GetApiLike(userId, patternId);

            if (apiLike == null)
            {
                var user    = usersRepository.GetById(userId);
                var pattern = patternsRepository.GetById(patternId);
                if (user != null && pattern != null)
                {
                    var like = new Like()
                    {
                        User    = user,
                        Pattern = pattern
                    };
                    likesRepository.Save(like);
                    apiLike = likesRepository.GetApiLike(userId, patternId);
                }
            }
            return(apiLike);
        }