Beispiel #1
0
        public void Add_OCRPaymentRecords()
        {
            DLModel2.CheckNumber     = "1R2O3H4I5T";
            DLModel2.CheckUploadName = "CHECK132.pdf";
            DLModel2.CreatedBy       = 2;
            DLModel2.FileID          = 5;
            DLModel2.InvoiceID       = 1;
            DLModel2.OCRId           = 1;
            DLModel2.PaymentAmount   = decimal.Parse("13");
            DLModel2.PaymentId       = 1;
            DLModel2.PaymentReceived = System.DateTime.Now;
            DLModel2.CheckDate       = System.DateTime.Now;
            var OCRPayment = _IOCRImplBL.AddOCRPaymentRecords(DLModel2);

            Assert.IsTrue(OCRPayment != null, "Unable to find");
        }
        public ActionResult AddOCRPaymentRecords(IEnumerable <OCRPaymentSave> objOCRPaymentSave)
        {
            try
            {
                var result = 0;
                var ocrID  = 0;
                if (objOCRPaymentSave != null)
                {
                    var objOCRpaymentList = objOCRPaymentSave.ToList();
                    foreach (var objocrPaymentSaveModel in objOCRpaymentList)
                    {
                        if (result == 0)
                        {
                            ocrID = objocrPaymentSaveModel.OCRId;
                        }
                        objocrPaymentSaveModel.OCRId     = ocrID;
                        objocrPaymentSaveModel.CreatedBy = Convert.ToInt32(Request.Cookies[GlobalConst.SessionKeys.userDetailMgmt].Values[GlobalConst.SessionKeys.userID]);
                        OCRPayment ObjOCRPayment = new OCRPayment();
                        int        _PaymentId    = _ocr.AddOCRPaymentRecords(Mapper.Map <LMGEDI.Core.Data.Model.OCRPaymentSave>(objocrPaymentSaveModel)).PaymentId;
                        _storageServices.CreatePaymentCheckFolder(objocrPaymentSaveModel.FileID, objocrPaymentSaveModel.InvoiceID, _PaymentId, Server.MapPath(ConfigurationManager.AppSettings[GlobalConst.ConstantChar.StoragePath]));
                        System.IO.File.Copy(Server.MapPath(ConfigurationManager.AppSettings[GlobalConst.ConstantChar.StoragePath].ToString()) + GlobalConst.ConstantChar.DoubleSlash +
                                            GlobalConst.ConstantChar.OCRUploads + GlobalConst.ConstantChar.DoubleSlash + objocrPaymentSaveModel.CheckUploadName,
                                            Path.Combine(Server.MapPath(ConfigurationManager.AppSettings[GlobalConst.ConstantChar.StoragePath]), objocrPaymentSaveModel.FileID.ToString(), objocrPaymentSaveModel.InvoiceID.ToString(), _PaymentId.ToString(), objocrPaymentSaveModel.CheckUploadName), true);

                        if (result == 0)
                        {
                            OCRModel ocrModel = new OCRModel();
                            ocrModel = Mapper.Map <OCRModel>(_ocr.GetOCRDetailById(ocrID));
                            ocrModel.IsOCRPaymentRecevied = true;
                            int OCRUpdated = _ocr.UpdateOCRRecord(Mapper.Map <LMGEDI.Core.Data.Model.OCR>(ocrModel));
                        }
                        result = 1;
                    }
                }
                else
                {
                    result = 2;
                }
                return(Json(result));
            }
            catch (Exception ex)
            {
                _arCommonService.CreateErrorLog(ex.Message, ex.StackTrace);
                return(Json(GlobalConst.ObjectTypes.Error));
            }
        }