public ActionResult Index(M_Cerificate Model) { B_CertificateRequest objCreq = new B_CertificateRequest(); string r = "Error"; Model.Createdby = _session.User_Id; Model.ParentId = _session.Customer_ID; Model.Status = "G";/// need to be change if the save certificate implemented including the CreateSample() string reff = objCreq.setCertificateRequest(Model); if (reff != null) { var DocumentUpload = Model.Support_Docs; if (DocumentUpload != null) { string DirectoryPath = "~/Uploads/Web_SDcouments/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MMM") + "/" + DateTime.Now.ToString("dd") + "/" + reff; if (!Directory.Exists(Server.MapPath(DirectoryPath))) { Directory.CreateDirectory(Server.MapPath(DirectoryPath)); } foreach (var Doc in DocumentUpload) { string strFileUpload = "file_" + Doc.SupportingDocument_Id; HttpPostedFileBase file = Request.Files[strFileUpload]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName.Replace(" ", "_")); var path = Path.Combine(Server.MapPath(DirectoryPath), fileName); M_SupportDocumentUpload Su = new M_SupportDocumentUpload(); Su.RequestRefNo = reff; Su.SignatureRequired = false; Su.SupportingDocumentID = Doc.SupportingDocument_Id; Su.UploadedBy = _session.User_Id; Su.UploadedPath = DirectoryPath + "/" + fileName; Su.DocumentName = fileName; if (Doc.Signature_Required) { Su.SignatureRequired = true; Su.Remarks = "NCE_Certification"; } else { Su.SignatureRequired = false; } objCreq.setSupportingDocumentFRequest(Su); file.SaveAs(path); } } } CreateSample(Model, reff); ViewBag._Result = "Succes"; r = "Succes"; } var result = new { Msg = r, Cid = Model.Client_Id, RqId = reff }; return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult Upload(M_Cerificate Model) { string r = "Error"; Model.Createdby = _session.User_Id; Model.ParentId = _session.Customer_ID; Model.Status = "P"; string CertificateFile = "Certificate_File"; HttpPostedFileBase Cfile = Request.Files[CertificateFile]; string DirectoryPath = "~/Uploads/" + DateTime.Now.ToString("yyyy") + "/Upload_Certificates/" + DateTime.Now.ToString("MMM") + "/" + DateTime.Now.ToString("dd") + "/"; Model.CertificateUploadPath = DirectoryPath; string reff = string.Empty; if (Cfile != null && Cfile.ContentLength > 0) { reff = objCr.setUploadBasedCertificateRequest(Model, Cfile.FileName.Replace(" ", "_")); if (reff != null) { DirectoryPath = DirectoryPath + reff; if (!Directory.Exists(Server.MapPath(DirectoryPath))) { Directory.CreateDirectory(Server.MapPath(DirectoryPath)); } var DocumentUpload = Model.Support_Docs; if (DocumentUpload != null) { string UDirectoryPath = "~/Uploads/" + DateTime.Now.ToString("yyyy") + "/Upload_CSDcouments/" + DateTime.Now.ToString("MMM") + "/" + DateTime.Now.ToString("dd") + "/" + reff; if (!Directory.Exists(Server.MapPath(UDirectoryPath))) { Directory.CreateDirectory(Server.MapPath(UDirectoryPath)); } foreach (var Doc in DocumentUpload) { string strFileUpload = "file_" + Doc.SupportingDocument_Id; HttpPostedFileBase Ufile = Request.Files[strFileUpload]; if (Ufile != null && Ufile.ContentLength > 0) { var fileName = Path.GetFileName(Ufile.FileName.Replace(" ", "_")); var path = Path.Combine(Server.MapPath(UDirectoryPath), fileName); M_SupportDocumentUpload Su = new M_SupportDocumentUpload(); Su.RequestRefNo = reff; Su.SignatureRequired = false; Su.SupportingDocumentID = Doc.SupportingDocument_Id; Su.UploadedBy = _session.User_Id; Su.UploadedPath = UDirectoryPath + "/" + fileName; Su.DocumentName = fileName; if (Doc.Signature_Required) { Su.SignatureRequired = true; Su.Remarks = "NCE_Certification"; } else { Su.SignatureRequired = false; } objCr.setSupportingDocumentFRequest(Su); Ufile.SaveAs(path); } } } var CfileName = Path.GetFileName(Cfile.FileName.Replace(" ", "_")); var Cpath = Path.Combine(Server.MapPath(DirectoryPath), CfileName); Cfile.SaveAs(Cpath); r = "Succes"; } } var result = new { Msg = r, Cid = Model.Client_Id, RqId = reff }; return(Json(result, JsonRequestBehavior.AllowGet)); }