public IActionResult AddComment(string id, string comment) { string uid = User.FindFirstValue(ClaimTypes.NameIdentifier); Favorites found = _context.Favorites.FirstOrDefault(x => (x.ApiId == id) && (x.UserId == uid)); found.CommentSection = comment; FavoritesListVM favoritesListVM = new FavoritesListVM(); favoritesListVM.ListOfFavoriteStartUps.Add(found); _context.Entry(found).State = EntityState.Modified; _context.Update(found); _context.SaveChanges(); return(RedirectToAction("Favorites", favoritesListVM)); }
public IActionResult AddComment(string id, string comment) { string uid = User.FindFirstValue(ClaimTypes.NameIdentifier); //Favorites found = _context.Favorites.FirstOrDefault(x => (x.ApiId == id) && (x.UserId == uid)); System.Security.Claims.ClaimsPrincipal currentUser = this.User; var foundIt = _context.Favorites.Find(id); foundIt.CommentSection = comment; _context.Entry(foundIt).State = EntityState.Modified; _context.Update(foundIt); _context.SaveChanges(); return(RedirectToAction("Favorites")); }