public ActionResult DeleteConfirmed(int id) { Wish_List wish_List = db.Wish_List.Find(id); db.Wish_List.Remove(wish_List); db.SaveChanges(); return(RedirectToAction("Index", new { id = wish_List.user_id })); }
// This test is responsible for checking the constructor public void Wish_ListTest_ConstructorWithNoValues_ShouldPass() { // Arrange // Act Wish_List wishList = new Wish_List(); // Assert Assert.IsNotNull(wishList); }
public ActionResult Edit([Bind(Include = "wish_list_id,user_id,game_id,date_added")] Wish_List wish_List) { if (ModelState.IsValid) { db.Entry(wish_List).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { id = wish_List.user_id })); } ViewBag.game_id = new SelectList(db.Games, "game_id", "game_name", wish_List.game_id); ViewBag.user_id = new SelectList(db.Users, "user_id", "username", wish_List.user_id); return(View(wish_List)); }
public ActionResult Edit([Bind(Include = "Wish_List_ID,RID,Item_ID,Create_Date,Hope_Delivery_Date,Status,Description,AuthorityCode")] Wish_List wish_List) { if (ModelState.IsValid) { db.Entry(wish_List).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Item_ID = new SelectList(db.Item, "Item_ID", "Item_Name", wish_List.Item_ID); ViewBag.RID = new SelectList(db.Refugee, "RID", "RefugeeFName", wish_List.RID); return(View(wish_List)); }
// GET: Wish_List/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Wish_List wish_List = db.Wish_List.Find(id); if (wish_List == null) { return(HttpNotFound()); } return(View(wish_List)); }
// This test is responsible for checking the date_added field public void Wish_ListTest_DateAddedWithCorrectType_ShouldPass() { // Arrange Wish_List wishList = new Wish_List(); DateTime expected = new DateTime(1995, 12, 23); DateTime actual = new DateTime(); // Act wishList.date_added = expected; // Assert actual = wishList.date_added; Assert.AreEqual(expected, actual); }
// This test is responsible for checking the game_id field public void Wish_ListTest_GameIDWithCorrectType_ShouldPass() { // Arrange Wish_List wishList = new Wish_List(); int expected = 23; int actual; // Act wishList.game_id = expected; // Assert actual = wishList.game_id; Assert.AreEqual(expected, actual); }
// GET: Wish_List/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Wish_List wish_List = db.Wish_List.Find(id); if (wish_List == null) { return(HttpNotFound()); } ViewBag.return_id = wish_List.user_id; return(View(wish_List)); }
// GET: Wish_List/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Wish_List wish_List = db.Wish_List.Find(id); if (wish_List == null) { return(HttpNotFound()); } ViewBag.Item_ID = new SelectList(db.Item, "Item_ID", "Item_Name", wish_List.Item_ID); ViewBag.RID = new SelectList(db.Refugee, "RID", "RefugeeFName", wish_List.RID); return(View(wish_List)); }
// GET: Wish_List/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Wish_List wish_List = db.Wish_List.Find(id); if (wish_List == null) { return(HttpNotFound()); } ViewBag.game_id = new SelectList(db.Games, "game_id", "game_name", wish_List.game_id); ViewBag.user_id = new SelectList(db.Users, "user_id", "username", wish_List.user_id); return(View(wish_List)); }
public ActionResult DeleteConfirmed(int id) { var username = User.Identity.Name; if (!string.IsNullOrEmpty(username)) { var user = db.Refugee.SingleOrDefault(u => u.AuthorityCode == username); string fullName = string.Concat(new string[] { user.RefugeeFName, " ", user.RefugeeLName }); ViewData.Add("FullName", fullName); } Wish_List wish_List = db.Wish_List.Find(id); wish_List.Status = "Deleted"; db.Entry(wish_List).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ShowWishList", new { code = User.Identity.Name })); }
public ActionResult Create([Bind(Include = "Wish_List_ID,RID,Item_ID,Create_Date,Hope_Delivery_Date,Status,Description,AuthorityCode")] Wish_List wish_List) { if (wish_List != null) { wish_List.Create_Date = DateTime.Now; wish_List.Status = "Not delivered"; } if (ModelState.IsValid) { db.Wish_List.Add(wish_List); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Item_ID = new SelectList(db.Item, "Item_ID", "Item_Name", wish_List.Item_ID); ViewBag.RID = new SelectList(db.Refugee, "RID", "RefugeeFName", wish_List.RID); return(View(wish_List)); }
public ActionResult Create([Bind(Include = "DonationID,DID,Wish_List_ID,Item_Name,Donate_Date,Status")] Donation donation, int id) { Wish_List wish = db.Wish_List.Find(id); wish.Status = "In processing"; db.Entry(wish).State = EntityState.Modified; db.SaveChanges(); //return RedirectToAction("Index"); if (ModelState.IsValid) { db.Donation.Add(donation); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DID = new SelectList(db.Donor, "DID", "FirstName", donation.DID); ViewBag.Wish_List_ID = new SelectList(db.Wish_List, "Wish_List_ID", "Status", donation.Wish_List_ID); return(View(donation)); }
public ActionResult Delete(int?id) { var username = User.Identity.Name; if (!string.IsNullOrEmpty(username)) { var user = db.Refugee.SingleOrDefault(u => u.AuthorityCode == username); string fullName = string.Concat(new string[] { user.RefugeeFName, " ", user.RefugeeLName }); ViewData.Add("FullName", fullName); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Wish_List wish_List = db.Wish_List.Find(id); if (wish_List == null) { return(HttpNotFound()); } return(View(wish_List)); }
public ActionResult Received(int id) { var username = User.Identity.Name; if (!string.IsNullOrEmpty(username)) { var user = db.Refugee.SingleOrDefault(u => u.AuthorityCode == username); string fullName = string.Concat(new string[] { user.RefugeeFName, " ", user.RefugeeLName }); ViewData.Add("FullName", fullName); } //delete the wishlist(make this record invisible) Wish_List wish_List = db.Wish_List.Find(id); wish_List.Status = "Completed"; db.Entry(wish_List).State = EntityState.Modified; db.SaveChanges(); //change information in donation table // Donation donation = wish_List.Donation.Where(d=>d.Wish_List_ID==id).FirstOrDefault(); // donation.Status = "Completed"; // db.Entry(donation).State = EntityState.Modified; // db.SaveChanges(); return(RedirectToAction("ShowWishList", new { code = User.Identity.Name })); }
public ActionResult Edit(int?id) { var username = User.Identity.Name; if (!string.IsNullOrEmpty(username)) { var user = db.Refugee.SingleOrDefault(u => u.AuthorityCode == username); string fullName = string.Concat(new string[] { user.RefugeeFName, " ", user.RefugeeLName }); ViewData.Add("FullName", fullName); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Wish_List wish_List = db.Wish_List.Find(id); if (wish_List == null) { return(HttpNotFound()); } ViewBag.Item_ID = new SelectList(db.Item, "Item_ID", "Item_Name", wish_List.Item_ID); ViewBag.RID = new SelectList(db.Refugee.Where(r => r.RID == wish_List.RID), "RID", "RefugeeFName", wish_List.RID); return(View(wish_List)); }
// GET: Donations/Create //button name: Donate public ActionResult Create(int id) { if (!User.Identity.Name.Contains("@")) { return(RedirectToAction("Login", "DonorRegister")); } else { //get the login donor information and refugee infomation // write this imformation to donation table Wish_List wish = db.Wish_List.Find(id); Refugee refugee = wish.Refugee; String email = User.Identity.Name; Donor donor = db.Donor.SingleOrDefault(d => d.Email == email); //update the status record in wishlist table // wish.Status = "In processing"; // if (ModelState.IsValid) // { // db.Entry(wish).State = EntityState.Modified; // db.SaveChanges(); // //return RedirectToAction("Index"); /// } //jump to donor, rufugee check page ViewBag.wishlistid = wish.Wish_List_ID; ViewBag.wish = wish; ViewBag.Item_Name = wish.Item.Item_Name; //ViewBag.reugee = refugee; ViewBag.donor = donor; ViewBag.fullAddress = donor.Street + " " + donor.Suburb + " " + donor.State; ViewBag.DID = new SelectList(db.Donor, "DID", "FirstName"); ViewBag.Wish_List_ID = new SelectList(db.Wish_List, "Wish_List_ID", "Status"); return(View()); } }