public ActionResult UpdateRatingFind(string value, string keyWord = "", int genre = 0, int year = 0) { MOVIEADVISOREntities6 entities = new MOVIEADVISOREntities6(); MOVIES_COMMENTS tempComment = new MOVIES_COMMENTS(); int rating = Int32.Parse(value.Split('/').Last()); tempComment.ID = entities.MOVIES_COMMENTS.OrderByDescending(mc => mc.ID).First().ID + 1; tempComment.MARK = rating; tempComment.USER_ID = entities.USERS.Where(u => u.USERNAME == User.Identity.Name).First().ID; tempComment.MOVIE_ID = Int32.Parse(value.Split('/').First()); entities.MOVIES_COMMENTS.AddObject(tempComment); entities.SaveChanges(); return(RedirectToAction("FindPost", new { keyWord = keyWord, genre = genre, year = year })); }
public ActionResult AddComment(string commentText, int movieId, int prevComment = 0) { MOVIEADVISOREntities6 entities = new MOVIEADVISOREntities6(); MOVIES_COMMENTS tempComment = new MOVIES_COMMENTS(); tempComment.MOVIE_ID = movieId; tempComment.TEXT = commentText; tempComment.USER_ID = entities.USERS.Where(u => u.USERNAME == User.Identity.Name).First().ID; tempComment.MARK = 10; tempComment.DATE = DateTime.Now; if (prevComment > 0) { tempComment.PREV_COMMENT_ID = prevComment; } tempComment.ID = entities.MOVIES_COMMENTS.OrderByDescending(mc => mc.ID).First().ID + 1; entities.MOVIES_COMMENTS.AddObject(tempComment); entities.SaveChanges(); return(RedirectToAction("Show", new { id = movieId })); }