Example #1
0
 public Int64 SaveTransaction(Transaction_Model transaction)
 {
     using (var _dbContext = new SalesTrackingSystemEntities())
     {
         try
         {
             var data = new Transaction()
             {
                 TransactionID    = GetNewTransactionID(),
                 TransactionLevel = transaction.TransactionLevel,
                 SupplierID       = transaction.SupplierID,
                 ReceiverID       = transaction.ReceiverID,
                 InvoiceNo        = transaction.InvoiceNo,
                 InvoiceDate      = transaction.InvoiceDate,
                 InvoiceEntryDate = DateTime.Now,
                 DiscountPercent  = transaction.DiscountPercent,
                 TaxPercent       = transaction.TaxPercent,
                 DateCreated      = DateTime.Now
             };
             _dbContext.Transactions.Add(data);
             _dbContext.SaveChanges();
             var transactionID = data.TransactionID;
             return(transactionID);
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
 public ActionResult TransactionAdd(Transaction_Model transaction)
 {
     if (string.IsNullOrWhiteSpace(transaction.InvoiceNo) || transaction.ReceiverID == 0)
     {
         ViewBag.AddError = "Error";
         return(View("Transaction"));
     }
     else
     {
         Int64 transactionID = transaction_Interface.SaveTransaction(transaction);
         if (transactionID != 0)
         {
             return(Json(transactionID));
         }
         else
         {
             Session["Error"] = "Transaction couldn't be done please retry!!";
         }
         return(RedirectToAction("Transaction"));
     }
 }