// GET: ProjectStudent/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectStudentModels projectStudentModels = db.ProjectStudentModels.Find(id); if (projectStudentModels == null) { return(HttpNotFound()); } string user_name = User.Identity.GetUserName(); if (projectStudentModels.StudentEmail != user_name) { return(HttpNotFound()); } var model = new PrijectFilesViewModels() { Project = projectStudentModels, Files = Directory.EnumerateFiles(projectStudentModels.FolderPath) }; return(View(model)); }
public ActionResult Comment(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectStudentModels projectStudentModels = db.ProjectStudentModels.Find(id); string user_name = User.Identity.GetUserName(); if (projectStudentModels.StudentEmail != user_name) { return(HttpNotFound()); } var model = new ProjectCommentsViewModels() { Project = projectStudentModels, Comments = db.CommentModels.Where(m => m.ProjectId == id).ToList() }; if (projectStudentModels == null) { return(HttpNotFound()); } return(View(model)); }
public ActionResult Mark([Bind(Include = "Id,ProjectName,Subject,StudentEmail,Class,StudentName,Grade,FolderPath")] ProjectStudentModels projectStudentModels) { if (ModelState.IsValid) { db.Entry(projectStudentModels).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(projectStudentModels)); }
public ActionResult UploadFiles(int Id) { ProjectStudentModels projectStudentModels = db.ProjectStudentModels.Find(Id); string user_name = User.Identity.GetUserName(); if (projectStudentModels.StudentEmail != user_name) { return(HttpNotFound()); } return(View()); }
public ActionResult DeleteConfirmed(int id) { ProjectStudentModels projectStudentModels = db.ProjectStudentModels.Find(id); if (Directory.Exists(projectStudentModels.FolderPath)) { Directory.Delete(projectStudentModels.FolderPath); } db.ProjectStudentModels.Remove(projectStudentModels); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Mark(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectStudentModels projectStudentModels = db.ProjectStudentModels.Find(id); if (projectStudentModels == null) { return(HttpNotFound()); } return(View(projectStudentModels)); }
public ActionResult Create([Bind(Include = "Id,ProjectName,Subject")] ProjectStudentModels projectStudentModels) { if (ModelState.IsValid) { string user_name = User.Identity.GetUserName(); string project_name = projectStudentModels.ProjectName; string project_subject = projectStudentModels.Subject; projectStudentModels.StudentEmail = user_name; string Class = db.StudentModels.Where(s => s.Email == user_name).SingleOrDefault().Class; projectStudentModels.Class = Class; string Name = db.AccountInfoModels.Where(s => s.Email == user_name).SingleOrDefault().Name; projectStudentModels.StudentName = Name; string path = Server.MapPath("~/Projects/") + user_name + "/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } db.ProjectStudentModels.Add(projectStudentModels); db.SaveChanges(); var project = db.ProjectStudentModels.Where(s => s.StudentEmail == user_name).Where(b => b.ProjectName == project_name).Where(c => c.Subject == project_subject).SingleOrDefault(); string path1 = Server.MapPath("~/Projects/") + user_name + "/" + project.Id + "/"; if (!Directory.Exists(path1)) { Directory.CreateDirectory(path1); } project.FolderPath = path1; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(projectStudentModels)); }
public ActionResult DeleteFile(string Path, int Id) { ProjectStudentModels projectStudentModels = db.ProjectStudentModels.Find(Id); string user_name = User.Identity.GetUserName(); if (projectStudentModels.StudentEmail != user_name) { return(HttpNotFound()); } if (System.IO.File.Exists(Path)) { System.IO.File.Delete(Path); } string redirectUrl = "/ProjectStudent/Details/" + Id; return(Redirect(redirectUrl)); }
public ActionResult Comment(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectStudentModels projectStudentModels = db.ProjectStudentModels.Find(id); var model = new ProjectCommentsViewModels() { Project = projectStudentModels, Comments = db.CommentModels.Where(m => m.ProjectId == id).ToList() }; if (projectStudentModels == null) { return(HttpNotFound()); } return(View(model)); }
// GET: ProjectStudent/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectStudentModels projectStudentModels = db.ProjectStudentModels.Find(id); if (projectStudentModels == null) { return(HttpNotFound()); } string user_name = User.Identity.GetUserName(); if (projectStudentModels.StudentEmail != user_name) { return(HttpNotFound()); } return(View(projectStudentModels)); }