예제 #1
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            videofile vd = db.videofiles.Find(id);

            if (vd == null)
            {
                return(HttpNotFound());
            }
            return(View(vd));
        }
예제 #2
0
 public ActionResult Index(videofile vd, HttpPostedFileBase videofile)
 {
     if (videofile != null)
     {
         string filename = Path.GetFileName(videofile.FileName);
         if (videofile.ContentLength < 104857600)
         {
             videofile.SaveAs(Server.MapPath("/Videofiles/" + filename));
             vd.Vname = filename;
             vd.Vpath = ("/Videofiles/" + filename);
             db.videofiles.Add(vd);
             db.SaveChanges();
         }
     }
     return(RedirectToAction("Display"));
 }
예제 #3
0
        public ActionResult Edit(int id, videofile vd, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                vd = db.videofiles.Find(id);
                if (file != null)
                {
                    string filename = Path.GetFileName(file.FileName);
                    if (file.ContentLength < 104857600)
                    {
                        file.SaveAs(Server.MapPath("/Videofiles/" + filename));
                        vd.Vname = filename;
                        vd.Vpath = ("/Videofiles/" + filename);

                        db.Entry(vd).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
            }
            return(RedirectToAction("Display"));
        }