示例#1
0
            public async Task <Payment> Add(Payment newPayment)
            {
                using (var db = new InvoiceMsDbContext(_dbName)) {
                    await db.AddAsync(newPayment);

                    await db.SaveChangesAsync();

                    return(newPayment);
                }
            }
示例#2
0
            public async Task <Invoice> Add(Invoice newInvoice)
            {
                using (var db = new InvoiceMsDbContext(_dbName)) {
                    await db.AddAsync(newInvoice);

                    await db.SaveChangesAsync();

                    return(newInvoice);
                }
            }
示例#3
0
            public async Task <bool> DeleteByID(int invoiceID)
            {
                using (var db = new InvoiceMsDbContext(_dbName)) {
                    var itemToDelete = await db.Invoices.FirstOrDefaultAsync(n => n.InvoiceID == invoiceID);

                    if (itemToDelete == null)
                    {
                        return(false);
                    }

                    db.Invoices.Remove(itemToDelete);
                    await db.SaveChangesAsync();

                    return(true);
                }
            }
示例#4
0
 public async Task <Payment> ByInvoiceID(int invoiceID)
 {
     using (var db = new InvoiceMsDbContext(_dbName)) {
         return(await db.Payments.FirstOrDefaultAsync(n => n.InvoiceID == invoiceID));
     }
 }
示例#5
0
 public async Task <List <Payment> > All()
 {
     using (var db = new InvoiceMsDbContext(_dbName)) {
         return(await db.Payments.AsNoTracking().ToListAsync());
     }
 }
示例#6
0
 public async Task <Invoice> ByShoppingCartID(long cartID)
 {
     using (var db = new InvoiceMsDbContext(_dbName)) {
         return(await db.Invoices.AsNoTracking().FirstOrDefaultAsync(n => n.ShoppingCartID == cartID));
     }
 }