public ActionResult DeleteConfirmed(int id) { Losttbl losttbl = db.Losttbls.Find(id); db.Losttbls.Remove(losttbl); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Title,Image,Category,Location,Details,SubLocation,DateOfLost")] Losttbl losttbl) { if (ModelState.IsValid) { db.Entry(losttbl).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(losttbl)); }
// GET: LostProducts/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Losttbl losttbl = db.Losttbls.Find(id); if (losttbl == null) { return(HttpNotFound()); } return(View(losttbl)); }
// GET: LostProducts/Details/5 public ActionResult Details(int?id) { // var lostproducts = db.Losttbls.Include(m => m.Category1).Include(m => m.SubCategory1).SingleOrDefault(x => x.Id == id); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Losttbl losttbl = db.Losttbls.Find(id); if (losttbl == null) { return(HttpNotFound()); } TempData["Title"] = db.Losttbls .Where(x => x.Id == id) .Select(x => x.Title) .FirstOrDefault(); TempData["Location"] = db.Losttbls .Where(x => x.Id == id) .Select(x => x.Location1.LocationName) .FirstOrDefault(); TempData["SubLocation"] = db.Losttbls .Where(x => x.Id == id) .Select(x => x.SubLocation1.SubLocationName) .FirstOrDefault(); TempData["Details"] = db.Losttbls .Where(x => x.Id == id) .Select(x => x.Details) .FirstOrDefault(); TempData["SubCategory"] = db.Losttbls .Where(x => x.Id == id) .Select(x => x.SubCategory1.SubCategoryName) .FirstOrDefault(); if (losttbl.UniqueKey != null) { TempData["Uniquekey"] = db.Losttbls .Where(x => x.Id == id) .Select(x => x.UniqueKey) .FirstOrDefault(); } return(View(losttbl)); }
public ActionResult Edit([Bind(Include = "Id,Title,Image,Type,Category,SubCategory,Location,SubLocation,DateOfFound,DateOfLost,FoundId,LostId,Details,OwnerName,CellNo,CategoryId,SubCategoryId,LocationId,SubLocationId,OwnerAddress,UniqueKey")] AdminApprovalTbl appoval, AllProductsTbl adminApprovalTbl, Foundtbl foundtbl, Losttbl losttbl, Topfoundtbl topfoundtbl, TopLosttbl toplosttbl) { if (ModelState.IsValid) { if (appoval.Type == "LOSTED") { db.AllProductsTbls.Add(adminApprovalTbl); db.Losttbls.Add(losttbl); } else if (appoval.Type == "TOP LOSTED") { db.AllProductsTbls.Add(adminApprovalTbl); db.Losttbls.Add(losttbl); db.TopLosttbls.Add(toplosttbl); } else if (appoval.Type == "FOUNDED") { db.AllProductsTbls.Add(adminApprovalTbl); db.Foundtbls.Add(foundtbl); } else if (appoval.Type == "TOP FOUNDED") { db.AllProductsTbls.Add(adminApprovalTbl); db.Foundtbls.Add(foundtbl); db.Topfoundtbls.Add(topfoundtbl); } // db.AllProductsTbls.Add(adminApprovalTbl); // db.Entry(adminApprovalTbl).State = EntityState.Modified; } ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", adminApprovalTbl.CategoryId); ViewBag.LocationId = new SelectList(db.Locations, "LocationId", "LocationName", adminApprovalTbl.LocationId); ViewBag.SubCategoryId = new SelectList(db.SubCategories, "SubCategoryId", "SubCategoryName", adminApprovalTbl.SubCategoryId); ViewBag.SubLocationId = new SelectList(db.SubLocations, "SubLocationId", "SubLocationName", adminApprovalTbl.SubLocationId); try { db.SaveChanges(); } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } } return(RedirectToAction("CreateConfirm")); // return View(appoval); }