// GET: Reviews/Edit/5 public ActionResult Edit(int?id, int?userGameID, bool?isAdmin) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Review review = db.Reviews.Find(id); if (review == null) { return(HttpNotFound()); } if (userGameID != null) { User_Game userGame = db.User_Game.Find(userGameID); ViewBag.datePurchased = userGame.date_purchased; ViewBag.rating = userGame.rating; } ViewBag.userGameID = userGameID; if (isAdmin != null) { ViewBag.isAdmin = isAdmin; } else { ViewBag.isAdmin = false; } return(View(review)); }
// GET: Reviews/Create public ActionResult Create(int?userGameID) { Review review = new Review(); if (userGameID != 0 || userGameID != null) { User_Game userGame = db.User_Game.Find(userGameID); ViewBag.rating = userGame.rating; ViewBag.rating = userGame.rating; Game game = db.Games.Find(userGame.game_id); User user = db.Users.Find(userGame.user_id); review.Game = game; review.User = user; review.user_id = user.user_id; review.game_id = game.game_id; review.review_date = DateTime.Now; review.review_content = ""; review.is_approved = false; review.is_deleted = false; } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViewBag.userGameID = userGameID; return(View(review)); }
public ActionResult DeleteConfirmed(int id) { User_Game user_Game = db.User_Game.Find(id); db.User_Game.Remove(user_Game); db.SaveChanges(); return(RedirectToAction("Index")); }
// This test is responsible for checking the user_id field public void User_GameTest_ConstructorWithNoValues_ShouldPass() { // Arrange // Act User_Game userGame = new User_Game(); // Assert Assert.IsNotNull(userGame); }
public ActionResult Edit([Bind(Include = "user_game_id,user_id,game_id,date_purchased,rating")] User_Game user_Game) { if (ModelState.IsValid) { db.Entry(user_Game).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user_Game)); }
public ActionResult Create([Bind(Include = "user_game_id,user_id,game_id,date_purchased,rating")] User_Game user_Game) { if (ModelState.IsValid) { db.User_Game.Add(user_Game); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.game_id = new SelectList(db.Games, "game_id", "game_name", user_Game.game_id); ViewBag.user_id = new SelectList(db.Users, "user_id", "username", user_Game.user_id); return(View(user_Game)); }
// GET: User_Game/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User_Game user_Game = db.User_Game.Find(id); if (user_Game == null) { return(HttpNotFound()); } return(View(user_Game)); }
// This test is responsible for checking the date_purchased field public void User_GameTest_DatePurchasedWithCorrectType_ShouldPass() { // Arrange User_Game UserGame = new User_Game(); DateTime expected = new DateTime(2000, 1, 1); DateTime actual = new DateTime(); // Act UserGame.date_purchased = expected; // Assert actual = UserGame.date_purchased; Assert.AreEqual(expected, actual); }
// This test is responsible for checking the game_id field public void User_GameTest_GameIDWithCorrectType_ShouldPass() { // Arrange User_Game userGame = new User_Game(); int expected = 43; int actual; // Act userGame.game_id = expected; // Assert actual = userGame.game_id; Assert.AreEqual(expected, actual); }
// This test is responsible for checking the rating field public void User_GameTest_RatingWithCorrectType_ShouldPass() { // Arrange User_Game userGame = new User_Game(); int expected = 43; int? actual; // Act userGame.rating = expected; // Assert actual = userGame.rating; Assert.AreEqual(expected, actual); }
// GET: User_Game/Edit/5 public ActionResult Edit(int?id, int?reviewID) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User_Game user_Game = db.User_Game.Find(id); if (user_Game == null) { return(HttpNotFound()); } List <int> rating = new List <int>(); for (int i = 1; i < 6; i++) { rating.Add(i); } ViewBag.reviewID = reviewID; ViewBag.rating = new SelectList(rating, user_Game.rating); return(View(user_Game)); }
// GET: Reviews/Edit/5 public ActionResult Edit(int?id, int?userGameID, bool?approve, bool?delete) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Review review = db.Reviews.Find(id); if (review == null) { return(HttpNotFound()); } if (userGameID != 0) { User_Game userGame = db.User_Game.Find(userGameID); ViewBag.datePurchased = userGame.date_purchased; ViewBag.rating = userGame.rating; } ViewBag.userGameID = userGameID; return(View(review)); }