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

                    await db.SaveChangesAsync();

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

                    await db.SaveChangesAsync();

                    return(newInvoice);
                }
            }
Exemple #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);
                }
            }