예제 #1
0
 public void removeTransaction()
 {
     using (MyDBContext db = new MyDBContext())
     {
         db.Transactions.Attach(this);
         db.Transactions.Remove(this);
         db.SaveChanges();
     }
 }
예제 #2
0
 public void removeInvoice()
 {
     using (MyDBContext db = new MyDBContext())
     {
         var transactions = db.Transactions.Where(x => x.invoiceId == invoiceId);
         db.Invoices.Attach(this);
         db.Invoices.Remove(this);
         db.SaveChanges();
         foreach (var transaction in transactions)
         {
             transaction.removeTransaction();
         }
     }
 }
예제 #3
0
 public void removeCustomer()
 {
     using (MyDBContext db = new MyDBContext())
     {
         var invoices = db.Invoices.Where(x => x.customerId == customerId);
         db.Customers.Attach(this);
         db.Customers.Remove(this);
         db.SaveChanges();
         foreach (var invoice in invoices)
         {
             invoice.removeInvoice();
         }
     }
 }
예제 #4
0
 public ActionResult InvoiceList(int customerId)
 {
     List<InvoiceViewModel> invoiceList = new List<InvoiceViewModel>();
     var dbInvoiceList = db.Invoices.Where(i => i.customerId == customerId);
     foreach (var invoice in dbInvoiceList)
     {
         using (MyDBContext dbCustomer = new MyDBContext())
         {
             var customer = dbCustomer.Customers.Find(invoice.customerId);
             invoiceList.Add(new InvoiceViewModel
             {
                 viewInvoiceId = invoice.invoiceId,
                 viewCustomerName = customer.customerName,
                 viewInvoiceDate = invoice.invoiceDate,
                 viewCustomerAdress = customer.customerAdress,
                 viewCustomerContact = customer.customerContact
             });
         }
     }
     return PartialView("_invoiceList", invoiceList);
 }
예제 #5
0
        public ActionResult InvoiceTransactions(int invoiceId)
        {
            List<Transaction> transactionList = db.Transactions.Where(t => t.invoiceId == invoiceId).ToList();
            List<TransactionViewModel> viewTransactionList = new List<TransactionViewModel>();

            foreach (var transaction in transactionList)
            {
                using (MyDBContext dbArticle = new MyDBContext())
                {
                    var article = dbArticle.Articles.Find(transaction.articleId);
                    viewTransactionList.Add(new TransactionViewModel
                    {
                        viewTransactionId = transaction.transactionId,
                        viewArticleName = article.articleName,
                        viewPrice = article.articlePrice,
                        quantity = transaction.quantity
                    });
                }
            }
            return PartialView("_invoiceTransactions", viewTransactionList);
        }