コード例 #1
0
        public async Task <JsonResult> SubmitFile(HttpPostedFileBase file, string Event_ID, string Submit_ID)
        {
            FileStream stream;

            if (file != null)
            {
                string path = Path.Combine(Server.MapPath("~/Content/tempFile"), file.FileName);
                file.SaveAs(path);
                stream = new FileStream(Path.Combine(path), FileMode.Open);
                await Task.Run(() => Upload(stream, file.FileName, path));

                SUBMIT sub = new SUBMIT();
                sub.ID       = Submit_ID;
                sub.EVENT_ID = Event_ID;
                sub.USER_ID  = (Session[CommonConstants.SESSION] as Session).id_user;
                sub.LINK     = CommonConstants.linkFile;
                sub.TIME     = DateTime.Now;
                SubmitDAO submitDAO = new SubmitDAO();
                if (submitDAO.InsertSubmit(sub))
                {
                    return(Json(new { status = true, file = new { filename = file.FileName, link = CommonConstants.linkFile } }));
                }
            }
            return(Json(new { status = false }));
        }
コード例 #2
0
ファイル: SubmitDAO.cs プロジェクト: war-man/LMS_Project
 public bool InsertSubmit(SUBMIT submit)
 {
     try
     {
         db.SUBMITs.Add(submit);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #3
0
ファイル: SubmitDAO.cs プロジェクト: war-man/LMS_Project
 public bool DeleteSubmit(string id)
 {
     try
     {
         SUBMIT submit = db.SUBMITs.First(x => x.ID == id);
         db.SUBMITs.Remove(submit);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #4
0
ファイル: SubmitDAO.cs プロジェクト: war-man/LMS_Project
 public bool UpdateSubmit(SUBMIT submit)
 {
     try
     {
         var sb = db.SUBMITs.Find(submit.ID);
         sb.ID       = submit.ID;
         sb.LINK     = submit.LINK;
         sb.TIME     = submit.TIME;
         sb.EVENT_ID = submit.EVENT_ID;
         sb.USER_ID  = submit.USER_ID;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }