public dynamic Post(Trans_TicketDTO objtasktransactionDTO) { Trans_Ticket objtasktransaction = new Trans_Ticket { TaskID = objtasktransactionDTO.TaskID, Comments = objtasktransactionDTO.Comments, AttachmentName = objtasktransactionDTO.AttachmentName, AttachmentPath = objtasktransactionDTO.AttachmentPath, CreatedBy = objtasktransactionDTO.CreatedBy, CreatedDate = objtasktransactionDTO.CreatedDate }; return(TaskTransactionRepository.AddComment(objtasktransaction)); }
public ActionResult Comment(string CommentText, string Tid) { UploadDocumentDTO objuploaddocument; if (Request.Files.Count > 0) { HttpPostedFileBase objfile = Request.Files[0]; byte[] binaryData; binaryData = new Byte[objfile.InputStream.Length]; long bytesRead = objfile.InputStream.Read(binaryData, 0, (int)objfile.InputStream.Length); objfile.InputStream.Close(); string base64String = System.Convert.ToBase64String(binaryData, 0, binaryData.Length); objuploaddocument = new UploadDocumentDTO { FileName = objfile.FileName, Format = objfile.ContentType.Split('/')[1], Base64String = base64String }; // upload document CustomResponse restype5 = APICalls.Post("UploadDocument/Post", objuploaddocument); if (restype5.Response != null) { var path = restype5.Response.ToString(); Trans_TicketDTO objcomment = new Trans_TicketDTO { TaskID = Convert.ToInt32(Tid), AttachmentName = objfile.FileName, AttachmentPath = path, CreatedBy = User.Identity.GetUserId(), CreatedDate = DateTime.Now, Comments = CommentText }; CustomResponse objcreatedocres = APICalls.Post("TaskTrasactionsAPI/Post", objcomment); if (objcreatedocres.Status == CustomResponseStatus.Successful) { return(RedirectToRoute("EditTicketRoute", new { ticketid = Tid })); } } } else { Trans_TicketDTO objcomment = new Trans_TicketDTO { TaskID = Convert.ToInt32(Tid), AttachmentName = null, AttachmentPath = null, CreatedBy = User.Identity.GetUserId(), CreatedDate = DateTime.Now, Comments = CommentText }; CustomResponse objcreatedocres = APICalls.Post("TaskTrasactionsAPI/Post", objcomment); if (objcreatedocres.Status == CustomResponseStatus.Successful) { return(RedirectToRoute("EditTicketRoute", new { ticketid = Tid })); } } return(RedirectToRoute("EditTicketRoute", new { ticketid = Tid })); }