Ejemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "ID,Naslov,Tekst,DatumObjave,Slika")] Vesti vesti, HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                try
                {
                    Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Imgs/Vesti"), vesti.ID.ToString()));
                    string path = Path.Combine(Server.MapPath("~/Imgs/Vesti/" + vesti.ID.ToString()),
                                               Path.GetFileName(file.FileName));
                    file.SaveAs(path);
                }
                catch (Exception ex)
                {
                    Session["Obavestenje"] = "ERROR:" + ex.Message.ToString();
                }
            }

            if (ModelState.IsValid)
            {
                db.Entry(vesti).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(vesti));
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Vesti  vesti = db.Vestis.Find(id);
            string path  = Server.MapPath(@"~/Imgs/Vesti/" + vesti.ID.ToString());

            Directory.Delete(path, true);
            db.Vestis.Remove(vesti);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        // GET: Vestis/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Vesti vesti = db.Vestis.Find(id);

            if (vesti == null)
            {
                return(HttpNotFound());
            }
            return(View(vesti));
        }
Ejemplo n.º 4
0
 // GET: Vestis/Edit/5
 public ActionResult Edit(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     if (Session["IDAdmina"] != null)
     {
         Vesti vesti = db.Vestis.Find(id);
         if (vesti == null)
         {
             return(HttpNotFound());
         }
         return(View(vesti));
     }
     return(RedirectToAction("Index", "Home"));
 }