//[AllowAnonymous] public ActionResult ViewUser(UserInfoIDModel ureq) { using (var db = new WishlistContext()) { var userProfile = db.UserProfiles.FirstOrDefault(u => u.UserId == ureq.ID); var userModel = new UserInfoJsonModel { ID = ureq.ID, UserName = userProfile == null ? "" : userProfile.UserName }; return(View(userModel)); } }
public ActionResult GetPublicWishlists(UserInfoIDModel ureq) { using (var db = new WishlistContext()) { var userProfile = db.UserProfiles.FirstOrDefault(u => u.UserId == ureq.ID); var userName = userProfile == null ? null : userProfile.UserName; var jsonModel = new UserJsonModel { UserID = ureq.ID, UserName = userName, Wishlists = db.Wishlists .Where(wl => wl.UserId == ureq.ID && wl.IsPublic) .AsEnumerable() .Select(wl => new WishlistFullJsonModel { Info = new WishlistJsonModel { ID = wl.WishlistId, Title = wl.WishlistTitle, IsPublic = wl.IsPublic }, WishlistItems = wl.WishlistItems .AsEnumerable() .Select(wli => new WishlistItemJsonModel { ID = wli.WishlistItemId, Content = wli.WishlistItemContent }) .ToArray() }) .ToArray() }; return(Json(jsonModel)); } }