public LikesDislikesViewModel GetLikesAndDislikesCount(int JokeId) { var jokeRepo = new JokesRepository(_connectionString); Jokes j = jokeRepo.GetJokesId(JokeId); LikesDislikesViewModel ldl = new LikesDislikesViewModel(); ldl.LikesCount = j.UserjokeLikes.Where(ulj => ulj.Liked == true).ToList().Count(); ldl.DislikesCount = j.UserjokeLikes.Where(ulj => ulj.Liked == false).ToList().Count(); return(ldl); }
public JokeWithCounteViewModel GetJokeForId(int JokeId) { JokesRepository repos = new JokesRepository(_connectionString); Jokes j = repos.GetJokesId(JokeId); JokeWithCounteViewModel joke = new JokeWithCounteViewModel { Id = j.Id, Setup = j.Setup, Punchline = j.Punchline, LikeCount = j.UserjokeLikes.Where(ulj => ulj.Liked == true).ToList().Count, DislikeCount = j.UserjokeLikes.Where(ulj => ulj.Liked == false).ToList().Count }; return(joke); }