public ActionResult Upload(HomeworkModel model, string returnUrl, string topic_id)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     try
     {
         System.Diagnostics.Debug.WriteLine(model.TopicId);
         System.Diagnostics.Debug.WriteLine(model.Author);
         if (model.UploadFile.ContentLength > 0)
         {
             string fileName = Path.GetFileName(model.UploadFile.FileName);
             string path     = Path.Combine(Server.MapPath("~/Static/Homework/"), topic_id + "_" + User.Identity.GetUserName() + "_" + fileName);
             model.UploadFile.SaveAs(path);
         }
         ViewBag.Message = "File Uploaded Successfully!!";
         var database = new HomeworkDataBase();
         database.accessDataBase();
         database.insertHomwork(model, User.Identity.GetUserName(), topic_id, topic_id + "_" + User.Identity.GetUserName() + "_" + Path.GetFileName(model.UploadFile.FileName));
         return(RedirectToAction("Index", "Topic"));
     }
     catch
     {
         ViewBag.Message = "File upload failed!!";
         return(View());
     }
 }
        public ActionResult Detail(string id)
        {
            ViewBag.upload_id = id;
            var database = new HomeworkDataBase();

            database.accessDataBase();
            return(View(database.getHomeworkById(id)));
        }
        public ActionResult List(string id)
        {
            System.Diagnostics.Debug.WriteLine(id);
            var database = new HomeworkDataBase();

            database.accessDataBase();

            ViewBag.topic_id = id;
            ViewBag.Title    = "C# final project";

            return(View(database.getHomeworkByTopicId(id)));
        }