Example #1
0
 public ActionResult Edit([Bind(Include = "id,lokacija,kapacitet")] mljekomati mljekomati)
 {
     if (ModelState.IsValid)
     {
         int userId = Int32.Parse(User.Identity.Name);
         mljekomati.id_korisnika    = userId;
         db.Entry(mljekomati).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(mljekomati));
 }
Example #2
0
        public ActionResult Create([Bind(Include = "id,lokacija,kapacitet")] mljekomati mljekomati)
        {
            if (ModelState.IsValid)
            {
                int userId = Int32.Parse(User.Identity.Name);
                mljekomati.id_korisnika = userId;
                db.mljekomati.Add(mljekomati);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_korisnika = new SelectList(db.gospodarstva, "id", "ime", mljekomati.id_korisnika);
            return(View(mljekomati));
        }
Example #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            mljekomati mljekomati = db.mljekomati.Find(id);

            try
            {
                db.mljekomati.Remove(mljekomati);
                db.SaveChanges();
            }
            catch
            {
                return(View("Error"));
            }
            return(RedirectToAction("Index"));
        }
Example #4
0
        // GET: mljekomati/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            mljekomati mljekomati = db.mljekomati.Find(id);
            int        userId     = Int32.Parse(User.Identity.Name);

            if (mljekomati == null || mljekomati.id_korisnika != userId)
            {
                return(HttpNotFound());
            }
            return(View(mljekomati));
        }
Example #5
0
        // GET: mljekomati/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            mljekomati mljekomati = db.mljekomati.Find(id);
            int        userId     = Int32.Parse(User.Identity.Name);
            string     x          = Url.RequestContext.RouteData.Values["id"].ToString();
            int        Ajdi       = Int32.Parse(x);

            if (mljekomati == null || mljekomati.id_korisnika != userId)
            {
                return(HttpNotFound());
            }
            ViewData["Servisi"]  = db.servisi_mljekomata.Where(f => f.id_mljekomata == Ajdi).ToList();
            ViewData["Punjenja"] = db.punjenje_mljekomata.Where(f => f.id_mljekomata == Ajdi).ToList();
            return(View(mljekomati));
        }