Esempio n. 1
0
 public ActionResult Upload(HttpPostedFileBase FilePath)
 {
     try
     {
         IPaymentTransactionService tranSrv = IoC.Resolve <IPaymentTransactionService>();
         Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
         if (FilePath != null && FilePath.ContentLength > 0)
         {
             byte[] bf = new byte[FilePath.ContentLength];
             FilePath.InputStream.Read(bf, 0, FilePath.ContentLength);
             if (!FilePath.FileName.ToLower().Contains(".xls"))
             {
                 Messages.AddErrorFlashMessage("File upload phải là file .xls hoặc .XLS!");
                 return(RedirectToAction("Upload"));
             }
             Guid guid = Guid.NewGuid();
             //thanh toan theo lo
             PaymentTransaction mTran = paymentViaBlock(bf);
             tranSrv.CreateNew(mTran);
             tranSrv.CommitChanges();
             Messages.AddFlashMessage("Upload file và gạch nợ xong, mã giao dịch: " + mTran.id);
             return(RedirectToAction("PaymentTransactionIndex"));
         }
         Messages.AddErrorFlashMessage("Chọn file cần upload!");
         return(RedirectToAction("Upload"));
     }
     catch (Exception ex)
     {
         Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng kiểm tra log để biết thêm chi tiết.");
         return(View("Upload"));
     }
 }