public ActionResult GetLiked(int[] ids) { if (CurrentSession.User != null) { int userid = CurrentSession.User.Id; List <int> likedNoteIds = new List <int>(); if (ids != null) { likedNoteIds = likeManager.List( x => x.LikedUser.Id == userid && ids.Contains(x.Note.Id)).Select( x => x.Note.Id).ToList(); } else { likedNoteIds = likeManager.List( x => x.LikedUser.Id == userid).Select( x => x.Note.Id).ToList(); } return(Json(new { result = likedNoteIds })); } else { return(Json(new { result = new List <int>() })); } }
public ActionResult GetLikedIds(int[] ids) { List <int> likedIds = new List <int>(); User currentUser = CurrentCookieTester.GetCurrentUser(CookieKeys.signedUserToken); if (currentUser != null) { likedIds = _likeManager.List(x => x.User.Id == currentUser.Id) .Where(x => ids.Contains(x.Note.Id)).GroupBy(x => x.Note.Id).Select(x => x.First()) .Select(x => x.Note.Id).ToList(); } return(Json(new { result = likedIds })); }
public ActionResult GetFavorites(int[] ids) { if (UserSession.User != null) { int userId = UserSession.User.Id; List <int> favFoodIds = new List <int>(); if (ids != null) { favFoodIds = likeManager.List(x => x.LikedUsers.Id == userId && ids.Contains(x.Food.Id)).Select(x => x.Food.Id).ToList(); } else { favFoodIds = likeManager.List(x => x.LikedUsers.Id == userId).Select(x => x.Food.Id).ToList(); } return(Json(new { result = favFoodIds })); } else { return(Json(new { result = new List <int>() })); } }