示例#1
0
        public ActionResult Edit([Bind(Include = "id,id_korisnika,koordinate,dimenzije,id_grada,lokacija,naziv")] parcele parcele)
        {
            if (ModelState.IsValid)
            {
                db.Entry(parcele).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_grada = new SelectList(db.gradovi, "id", "ime", parcele.id_grada);
            return(View(parcele));
        }
示例#2
0
        public ActionResult Create([Bind(Include = "id,koordinate,dimenzije,id_grada,lokacija,naziv")] parcele parcele)
        {
            parcele.id_korisnika = DobaviID();

            if (ModelState.IsValid)
            {
                db.parcele.Add(parcele);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_korisnika = new SelectList(db.gospodarstva, "id", "ime", parcele.id_korisnika);
            ViewBag.id_grada     = new SelectList(db.gradovi, "id", "ime", parcele.id_grada);
            return(View(parcele));
        }
示例#3
0
        // GET: parcele/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            parcele parcele = db.parcele.Find(id);
            var     userId  = DobaviID();

            if (parcele == null || parcele.id_korisnika != userId)
            {
                return(HttpNotFound());
            }
            return(View(parcele));
        }
示例#4
0
        public ActionResult DeleteConfirmed(int id)
        {
            parcele parcele = db.parcele.Find(id);

            try
            {
                db.parcele.Remove(parcele);
                db.SaveChanges();
            }
            catch
            {
                return(View("Error"));
            }

            return(RedirectToAction("Index"));
        }
示例#5
0
        // GET: parcele/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            parcele parcele = db.parcele.Find(id);
            var     userId  = DobaviID();

            if (parcele == null || parcele.id_korisnika != userId)
            {
                return(HttpNotFound());
            }
            ViewBag.id_korisnika = new SelectList(db.gospodarstva, "id", "ime", parcele.id_korisnika);
            ViewBag.id_grada     = new SelectList(db.gradovi, "id", "ime", parcele.id_grada);
            return(View(parcele));
        }
示例#6
0
        // GET: parcele/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            parcele parcele = db.parcele.Find(id);
            var     userId  = DobaviID();

            if (parcele == null || parcele.id_korisnika != userId)
            {
                return(HttpNotFound());
            }
            ViewData["Farme"]   = db.farme.Where(f => f.parcele.id == id).ToList();
            ViewData["Oranice"] = db.oranice.Where(o => o.parcele.id == id).ToList();
            return(View(parcele));
        }
示例#7
0
        // GET: farme/Create
        public ActionResult Create()
        {
            int userId = Int32.Parse(User.Identity.Name);

            ViewBag.id_parcele = new SelectList(db.parcele.Where(p => p.id_korisnika == userId), "id", "naziv");

            if (Url.RequestContext.RouteData.Values["id"] != null)
            {
                string id = Url.RequestContext.RouteData.Values["id"].ToString();

                parcele parcela = db.parcele.Find(Int32.Parse(id));
                if (parcela == null || parcela.id_korisnika != userId)
                {
                    return(HttpNotFound());
                }
            }

            return(View());
        }