public ActionResult Create(uploadingfileviewmodel model)
        {
            if (ModelState.IsValid)
            {
                if (model.file == null || model.file.ContentLength == 0)
                {
                    ModelState.AddModelError("Please Upload the File To Proceed", "This field is Required");
                }



                if (model.file != null && model.file.ContentLength > 0)
                {
                    var uploadDir = "~/UploadedFiles";
                    var filepath  = Path.Combine(Server.MapPath(uploadDir), model.file.FileName);
                    var fileurl   = Path.Combine(uploadDir, model.file.FileName);
                    model.file.SaveAs(filepath);
                    CollegeFiles collegefiles = new CollegeFiles();
                    collegefiles.filepath        = fileurl;
                    collegefiles.FileCat         = model.FileCat;
                    collegefiles.FileDescription = model.FileDescription;

                    collegefiles.uploderid = user.RegistrationNo;//here i hard coded for the testing and working purpose (dynamic added now its working and fully dynamic sloved the hardcoded)
                    var getname = (from alias in db.Teachers where alias.Id == collegefiles.uploderid select alias.TeacherName).FirstOrDefault();
                    collegefiles.UploadingDate = DateTime.Now;
                    collegefiles.Uploadername  = getname;
                    db.CollegeFiles.Add(collegefiles);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            return(View(model));
        }
 public ActionResult Edit(CollegeFiles collegefiles)
 {
     if (ModelState.IsValid)
     {
         db.Entry(collegefiles).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(collegefiles));
 }
        public ActionResult DeleteConfirmed(int id)
        {
            CollegeFiles collegeFiles = db.CollegeFiles.Find(id);

            if (System.IO.File.Exists(collegeFiles.filepath))
            {
                System.IO.File.Delete(collegeFiles.filepath);
            }
            db.CollegeFiles.Remove(collegeFiles);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: CollegeFiles/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CollegeFiles collegeFiles = db.CollegeFiles.Find(id);

            if (collegeFiles == null)
            {
                return(HttpNotFound());
            }
            return(View(collegeFiles));
        }