public JsonResult Add(int id, string message) { var commentManager = new DataAccess.CommentManager(); var status = commentManager.Add(id, UserDetail.UserId, message, null); return Json(status); }
public JsonResult UploadAttachment() { var status = false; HttpPostedFileBase myFile = null; var fileResources = new List<DataModel.Modal.CommentAttachment>(); for (int i = 0; i < Request.Files.Count; i++) { if (Request.Files.Count > 0) myFile = Request.Files[i]; if (myFile != null && myFile.ContentLength != 0) { string pathForSaving = Server.MapPath("~/AttachmentUploads"); if (SharedFunction.CreateFolderIfNeeded(pathForSaving)) { try { string fileName = DateTime.Now.ToString("MMddyyyyHHmmss") + Path.GetExtension(myFile.FileName); myFile.SaveAs(Path.Combine(pathForSaving, fileName)); string path = "~/AttachmentUploads/" + fileName; fileResources.Add(new DataModel.Modal.CommentAttachment { FileResource = new DataModel.Modal.FileResource { name = myFile.FileName, path = path } }); } catch (Exception ex) { return Json(ex.InnerException); } } } } var commentManager = new DataAccess.CommentManager(); status = commentManager.Add(Convert.ToInt32(Request.Form["taskID"].ToString()), UserDetail.UserId, Request.Form["comment"].ToString(), fileResources); return Json(status); }