Exemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            CropPostModel cropPostModel = db.CropPostModels.Find(id);

            db.CropPostModels.Remove(cropPostModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
        // 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));
        }
Exemplo n.º 4
0
        // 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));
        }
Exemplo n.º 5
0
        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));
        }