Пример #1
0
        public ActionResult UploadFiles(string id, FileDataVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            byte[] uploadedFile = new byte[model.File.InputStream.Length];
            model.File.InputStream.Read(uploadedFile, 0, uploadedFile.Length);

            // now you could pass the byte array to your model and store wherever
            // you intended to store it
            File_tbl fl = new File_tbl()
            {
                FileName = model.File.FileName,
                UploadOn = DateTime.Now,
                File     = uploadedFile,
                CourseID = id
            };

            db.File_tbl.Add(fl);
            db.SaveChanges();
            db.Course_tbl.Find(id).PDFs = db.File_tbl.Where(m => m.CourseID == id).Count().ToString();
            db.SaveChanges();
            // add notification for every student registered to this course

            return(RedirectToAction("Create", "Notification", new { mthd = "Index", cntlr = "Course", course_id = id,
                                                                    subject = "New File is uploaded in ", role_not = "Student" }));
        }
Пример #2
0
        public ActionResult UploadAssig(string id, FileDataVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            byte[] uploadedFile = new byte[model.File.InputStream.Length];
            model.File.InputStream.Read(uploadedFile, 0, uploadedFile.Length);
            var assig = db.Event_tbl.Find(id);

            // now you could pass the byte array to your model and store wherever
            // you intended to store it
            File_tbl fl = new File_tbl()
            {
                FileName     = model.File.FileName,
                UploadOn     = DateTime.Now,
                File         = uploadedFile,
                CourseID     = assig.CourseID,
                AssignmentID = assig.ID
            };

            db.File_tbl.Add(fl);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Пример #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            File_tbl file_tbl = db.File_tbl.Find(id);

            db.File_tbl.Remove(file_tbl);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
        // GET: File/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            File_tbl file_tbl = db.File_tbl.Find(id);

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