public void Add_PaymentRecord() { DLModel.InvoiceId = 224; DLModel.PaymentAmount = 549; DLModel.PaymentReceived = System.DateTime.Now; DLModel.CheckNumber = "856974"; DLModel.CheckUploadName = "check.pdf"; int paymentId = _IPaymentImplBL.AddPaymentRecord(DLModel); Assert.IsTrue(true, "Unable to find"); }
public ActionResult SavePaymentRecord(Payment payment) { try { string[] extension = null; string path = GlobalConst.ConstantChar.Blank; string DownloadPath = GlobalConst.ConstantChar.Blank; string filename = GlobalConst.ConstantChar.Blank; if (payment.CheckUploadName1 != null) { filename = payment.CheckUploadName1.FileName; filename = filename.Substring(filename.LastIndexOf(GlobalConst.ConstantChar.SingleQouteDoubleSlash) + 1); extension = filename.Split(GlobalConst.ConstantChar.SingleQouteDot); } if (payment.PaymentId == 0) { if (extension != null) { payment.CheckUploadName = Guid.NewGuid().ToString() + GlobalConst.Extension.PDF; } payment.PaymentId = _payment.AddPaymentRecord(Mapper.Map <LMGEDI.Core.Data.Model.Payment>(payment)); payment.flag = true; if (payment.PaymentId == -1) { payment.IsPaymentGreater = true; } if (extension != null && payment.PaymentId != 0 && payment.PaymentId != -1) { bool s = _storageServices.CreatePaymentCheckFolder(payment.FileID, payment.InvoiceId, payment.PaymentId, Server.MapPath(ConfigurationManager.AppSettings[GlobalConst.ConstantChar.StoragePath])); path = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings[GlobalConst.ConstantChar.StoragePath]), payment.FileID.ToString(), payment.InvoiceId.ToString(), payment.PaymentId.ToString()); DownloadPath = Path.Combine(ConfigurationManager.AppSettings[GlobalConst.ConstantChar.StoragePath], payment.FileID.ToString(), payment.InvoiceId.ToString(), payment.PaymentId.ToString()); payment.CheckUploadName1.SaveAs(path + GlobalConst.ConstantChar.DoubleSlash + payment.CheckUploadName); payment.CheckDownloadPath = DownloadPath + GlobalConst.ConstantChar.DoubleSlash + payment.CheckUploadName; } } else { string filename1 = GlobalConst.ConstantChar.Blank; if (extension != null) { filename1 = Guid.NewGuid().ToString() + GlobalConst.Extension.PDF; //DateTime.Now.ToString(GlobalConst.ConstantChar.ddMMyyyyss) + GlobalConst.ConstantChar.Dot + extension[1]; } path = Path.Combine(Server.MapPath(ConfigurationManager.AppSettings[GlobalConst.ConstantChar.StoragePath]), payment.FileID.ToString(), payment.InvoiceId.ToString(), payment.PaymentId.ToString()); DownloadPath = Path.Combine(ConfigurationManager.AppSettings[GlobalConst.ConstantChar.StoragePath], payment.FileID.ToString(), payment.InvoiceId.ToString(), payment.PaymentId.ToString()); if (extension != null) { bool s = _storageServices.CreatePaymentCheckFolder(payment.FileID, payment.InvoiceId, payment.PaymentId, Server.MapPath(ConfigurationManager.AppSettings[GlobalConst.ConstantChar.StoragePath])); bool result = System.IO.File.Exists(path + GlobalConst.ConstantChar.DoubleSlash + payment.CheckUploadName); if (result) { System.IO.File.Delete(path + GlobalConst.ConstantChar.DoubleSlash + payment.CheckUploadName); } payment.CheckUploadName = filename1; } if (payment.CheckUploadName1 == null) { if (System.IO.File.Exists(path + GlobalConst.ConstantChar.DoubleSlash + payment.CheckUploadName)) { string uploadedfilename = Guid.NewGuid().ToString() + GlobalConst.Extension.PDF; System.IO.File.Move(path + GlobalConst.ConstantChar.DoubleSlash + payment.CheckUploadName, path + GlobalConst.ConstantChar.DoubleSlash + uploadedfilename); payment.CheckUploadName = uploadedfilename; } } int PaymentId = _payment.UpdatePaymentRecord(Mapper.Map <LMGEDI.Core.Data.Model.Payment>(payment)); if (PaymentId == -1) { payment.IsPaymentGreater = true; } if ((PaymentId != -1 && PaymentId != 0) && payment.CheckUploadName1 != null) { payment.CheckUploadName1.SaveAs(path + GlobalConst.ConstantChar.DoubleSlash + filename1); } payment.flag = false; payment.CheckDownloadPath = DownloadPath + GlobalConst.ConstantChar.DoubleSlash + payment.CheckUploadName; } payment.CheckUploadName1 = null; return(Json(payment, GlobalConst.ContentTypes.TextHtml)); } catch (Exception ex) { _arCommonService.CreateErrorLog(ex.Message, ex.StackTrace); return(View()); } }