public ActionResult DeleteConfirmed(int id) { CropPostModel cropPostModel = db.CropPostModels.Find(id); db.CropPostModels.Remove(cropPostModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "CropPostId,Title,Description,UserModelId,Type")] CropPostModel cropPostModel) { if (ModelState.IsValid) { db.Entry(cropPostModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserModelId = new SelectList(db.UserModels, "Id", "PhoneNumber", cropPostModel.UserModelId); return(View(cropPostModel)); }
// GET: CropPost/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CropPostModel cropPostModel = db.CropPostModels.Find(id); if (cropPostModel == null) { return(HttpNotFound()); } return(View(cropPostModel)); }
// GET: CropPost/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CropPostModel cropPostModel = db.CropPostModels.Find(id); if (cropPostModel == null) { return(HttpNotFound()); } ViewBag.UserModelId = new SelectList(db.UserModels, "Id", "PhoneNumber", cropPostModel.UserModelId); return(View(cropPostModel)); }
public ActionResult Create([Bind(Include = "CropPostId,Title,Description,UserModelId,Type")] CropPostModel cropPostModel) { if (ModelState.IsValid) { UserModel user = (UserModel)Session["UserModel"]; cropPostModel.UserModelId = user.Id; if (user.Type == "Farmer") { cropPostModel.Type = "Crop"; } db.CropPostModels.Add(cropPostModel); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserModelId = new SelectList(db.UserModels, "Id", "PhoneNumber", cropPostModel.UserModelId); return(View(cropPostModel)); }