public JsonResult SignConsignmentContract(long id, string sellerSignature) { try { Consignment consignment = InvoiceRepository.GetConsignment(id); ConsignmentContract consignmentContract = InvoiceRepository.GetConsignmentContract(id); if (consignment == null || consignmentContract == null || consignmentContract.StatusID != (int)Consts.ConsignmentContractStatus.Unsigned || consignment.User_ID != AppHelper.CurrentUser.ID) { throw new Exception("Error occurred during the process of signing the document. Please reload page and try again"); } if (string.IsNullOrWhiteSpace(sellerSignature)) { throw new Exception("Draw signature as first."); } Specialist specialist = InvoiceRepository.GetSpecialist(consignment.Specialist_ID.GetValueOrDefault(-1)); if (specialist == null) { throw new Exception("Error occurred during the process of signing the document. Please contact us."); } string lelandsSignaturePath = AppHelper.SignatureImagesOnDisk(string.Format("userSignature{0}.png", specialist.User_ID)); FileInfo fileInfo = new FileInfo(lelandsSignaturePath); if (!fileInfo.Exists) { throw new Exception("Error occurred during the process of signing the document. Please contact us."); } SignatureToImage signature = new SignatureToImage(); Bitmap signatureImage = signature.SigJsonToImage(sellerSignature); string sellerSignaturePath = AppHelper.ConsignmentContractOnDisk(consignment.ID, consignmentContract.FileName.ToLower().Replace(".pdf", ".png")); fileInfo = new FileInfo(sellerSignaturePath); if (fileInfo.Exists) { fileInfo.Delete(); } signatureImage.Save(sellerSignaturePath); Address lelandsAddress = new Address { FirstName = "Lelands.com", LastName = Consts.SiteEmail, Address_1 = Consts.CompanyAddress, City = Consts.CompanyCity, State = Consts.CompanyState, Zip = Consts.CompanyZip, HomePhone = Consts.CompanyPhone, WorkPhone = Consts.CompanyFax }; User consignor = UserRepository.GetUser(consignment.User_ID, true); Address consignorAddress = Address.GetAddress(UserRepository.GetAddressCard(consignor.Billing_AddressCard_ID.GetValueOrDefault(0), true)); PdfReports.ConsignmentContract(AppHelper.ConsignmentContractOnDisk(consignment.ID, consignmentContract.FileName), AppHelper.PublicImagesOnDisk("logo.png"), string.Empty, Consts.CompanyTitleName, string.Empty, lelandsAddress, lelandsSignaturePath, consignorAddress, consignor.Email, sellerSignaturePath, DateTime.Now, InvoiceRepository.GetConsignmentDetailsByConsignmentID(id), consignmentContract.ContractText); consignmentContract.StatusID = (int)Consts.ConsignmentContractStatus.Signed; InvoiceRepository.UpdateConsignmentContract(consignmentContract); } catch (Exception exc) { return(JSON(new { success = false, exc.Message })); } return(JSON(new { success = true })); }
//ShowConsignmentContract public FileStreamResult ShowConsignmentContract(long id) { Consignment consignment = InvoiceRepository.GetConsignment(id); ConsignmentContract consignmentContract = InvoiceRepository.GetConsignmentContract(id); if (consignment == null || consignment.User_ID != AppHelper.CurrentUser.ID || consignmentContract == null || consignmentContract.StatusID == (int)Consts.ConsignmentContractStatus.NotGenerated || string.IsNullOrWhiteSpace(consignmentContract.FileName)) { return(null); } string path = AppHelper.ConsignmentContractOnDisk(consignment.ID, consignmentContract.FileName); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); return(File(fs, "application/pdf")); }
public ActionResult ConsignmentDetail(long id) { Consignment consignment = InvoiceRepository.GetConsignment(id); if (consignment == null || consignment.User_ID != AppHelper.CurrentUser.ID) { return(RedirectToAction("ConisgnorStatements")); } ConsignmentContract consignmentContract = InvoiceRepository.GetConsignmentContract(consignment.ID); ViewData["ConsignmentContract"] = consignmentContract; ViewData["ConsignmentStatement"] = consignment; ViewData["Event_Title"] = EventRepository.GetEventByID(consignment.Event_ID).Title; ViewData["ConsignmentTotals"] = InvoiceRepository.GetConsignmentTotals(id); return(View(InvoiceRepository.GetConsignmentDetailsByConsignmentID(id))); }
public FilePathResult DownloadConsignmentContract(long id) { try { Consignment consignment = InvoiceRepository.GetConsignment(id); ConsignmentContract consignmentContract = InvoiceRepository.GetConsignmentContract(id); if (consignment == null || consignment.User_ID != AppHelper.CurrentUser.ID || consignmentContract == null || consignmentContract.StatusID == (int)Consts.ConsignmentContractStatus.NotGenerated || string.IsNullOrWhiteSpace(consignmentContract.FileName)) { return(null); } string path = AppHelper.ConsignmentContractOnDisk(consignment.ID, consignmentContract.FileName); return(File(path, "application/pdf", consignmentContract.FileName)); } catch { return(null); } }
public void UpdateFields(ConsignmentContract cc) { UpdateFields(cc.ConsignmentID, cc.StatusID, cc.ContractText, cc.FileName); }