public ActionResult AddSubmittion(ParamInputCreateModel param) { int resCode = 0; try { var newSubmitID = dataAccess.CreateIDAuto("SM"); //var userInfo = dataAccess.GetUserInfoByID(2); var userInfo = (UserLoginModel)Session[Helper.Commons.USER_SEESION]; param.description = HttpUtility.HtmlDecode(RemoveHtmlTag(HttpUtility.HtmlDecode(param.description).Replace("<br />", "\n").Replace("</li>", "\n").Replace(" ", ""))); // lưu submittion var inforSubmit = new SUBMITTION() { Sub_Title = param.title, Sub_Description = param.description, Created_Date = DateTime.Now, Sub_Code = newSubmitID, Created_By = userInfo.UserID, IsPublic = 0 }; var newID = dataAccess.AddSubmits(inforSubmit); // lưu file của submitton if (param.files.Count() > 0) { string path = Server.MapPath("~/Uploads/FilesSubmitted/"); foreach (var item in param.files) { if (item != null) { var files = new FILE(); string fileName = string.Format("{0}_{1}_{2}{3}", userInfo.Username, newSubmitID, DateTime.Now.Ticks.ToString(), System.IO.Path.GetExtension(item.FileName)); files.File_Name = item.FileName; files.File_Path = fileName; files.Sub_Code = newSubmitID; files.Sub_ID = newID; // lưu file vào folder item.SaveAs(path + fileName); var insertFile = dataAccess.InsertFile(files); } } } Task.Run(() => Helper.SendMail.SendEmailWhenAddNewSubmittion(userInfo.UserID.ToString(), userInfo.Username, userInfo.Department, userInfo.Email, param.title, param.files.Count())); resCode = 1; } catch (Exception) { resCode = -1; throw; } return(Json(resCode, JsonRequestBehavior.AllowGet)); }