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); }