public async Task <data.InvoiceLine> Add(data.InvoiceContext db, InvoiceLineAdd add) { try { var newInvoiceLine = new data.InvoiceLine(); newInvoiceLine.LineTotal = add.LineTotal; newInvoiceLine.Notes = add.Notes; newInvoiceLine.Product = add.Product; newInvoiceLine.ProductCode = add.ProductCode; newInvoiceLine.Quantity = add.Quantity; newInvoiceLine.SubTotal = add.SubTotal; newInvoiceLine.TaxExempt = add.TaxExempt; newInvoiceLine.TaxTotal = add.TaxTotal; newInvoiceLine.UnitCost = add.UnitCost; var invoiceLookup = await db.Invoices.FirstOrDefaultAsync(w => w.InvoiceId == add.InvoiceInvoiceId); if (invoiceLookup != null) { newInvoiceLine.Invoice = invoiceLookup; } db.InvoiceLines.Add(newInvoiceLine); return(newInvoiceLine); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
public async Task <data.Invoice> Update(data.InvoiceContext db, InvoiceUpdate update) { try { var invoiceToUpdate = await db.Invoices.FirstOrDefaultAsync(w => w.InvoiceId == update.InvoiceId); invoiceToUpdate.BillingAddress = update.BillingAddress; invoiceToUpdate.CreatedDate = update.CreatedDate; invoiceToUpdate.DueDate = update.DueDate; invoiceToUpdate.EmailTo = update.EmailTo; invoiceToUpdate.GrandTotal = update.GrandTotal; invoiceToUpdate.InvoiceEmailed = update.InvoiceEmailed; invoiceToUpdate.InvoiceId = update.InvoiceId; invoiceToUpdate.InvoiceNo = update.InvoiceNo; invoiceToUpdate.Notes = update.Notes; invoiceToUpdate.OrderedBy = update.OrderedBy; invoiceToUpdate.PaidAmount = update.PaidAmount; invoiceToUpdate.PaidDate = update.PaidDate; invoiceToUpdate.PaidTax = update.PaidTax; invoiceToUpdate.PaymentDetails = update.PaymentDetails; invoiceToUpdate.PurchaseOrderRef = update.PurchaseOrderRef; invoiceToUpdate.ShippingAddress = update.ShippingAddress; invoiceToUpdate.SubTotal = update.SubTotal; invoiceToUpdate.TaxTotal = update.TaxTotal; invoiceToUpdate.TermsAndConditions = update.TermsAndConditions; return(invoiceToUpdate); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
public async Task <data.Customer> Add(data.InvoiceContext db, CustomerAdd add) { try { var newCustomer = new data.Customer(); newCustomer.Active = add.Active; newCustomer.Address = add.Address; newCustomer.CustomerExteranlRef = add.CustomerExteranlRef; newCustomer.EmailAddress = add.EmailAddress; newCustomer.IsCompany = add.IsCompany; newCustomer.Name = add.Name; newCustomer.PhoneNumber = add.PhoneNumber; newCustomer.TaxNo = add.TaxNo; var entityLookup = await db.Entitys.FirstOrDefaultAsync(w => w.EntityId == add.EntityEntityId); if (entityLookup != null) { newCustomer.Entity = entityLookup; } db.Customers.Add(newCustomer); return(newCustomer); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
public async System.Threading.Tasks.Task Delete(data.InvoiceContext db, EntityDelete delete) { try { var entityToDelete = await db.Entitys.FirstOrDefaultAsync(w => w.EntityId == delete.EntityId); db.Entitys.Remove(entityToDelete); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); } }
public async System.Threading.Tasks.Task Delete(data.InvoiceContext db, CounterDelete delete) { try { var counterToDelete = await db.Counters.FirstOrDefaultAsync(w => w.Name == delete.Name); db.Counters.Remove(counterToDelete); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); } }
public async Task <data.Counter> Add(data.InvoiceContext db, CounterAdd add) { try { var newCounter = new data.Counter(); newCounter.Value = add.Value; db.Counters.Add(newCounter); return(newCounter); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
// Delete Transaction Code public async System.Threading.Tasks.Task Delete(EntityDelete delete) { try { using (var db = new data.InvoiceContext()) { await Delete(db, delete); await db.SaveChangesAsync(); } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); } }
public async Task <data.Counter> Update(data.InvoiceContext db, CounterUpdate update) { try { var counterToUpdate = await db.Counters.FirstOrDefaultAsync(w => w.Name == update.Name); counterToUpdate.Name = update.Name; counterToUpdate.Value = update.Value; return(counterToUpdate); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
public async Task <data.PaymentHistory> Update(data.InvoiceContext db, PaymentHistoryUpdate update) { try { var paymentHistoryToUpdate = await db.PaymentHistorys.FirstOrDefaultAsync(w => w.PaymentHistoryId == update.PaymentHistoryId); paymentHistoryToUpdate.Amount = update.Amount; paymentHistoryToUpdate.PaymentDate = update.PaymentDate; paymentHistoryToUpdate.PaymentHistoryId = update.PaymentHistoryId; paymentHistoryToUpdate.Reference = update.Reference; return(paymentHistoryToUpdate); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
// Add Transaction Code public async Task <CounterView> Add(CounterAdd add) { try { using (var db = new data.InvoiceContext()) { var result = await Add(db, add); await db.SaveChangesAsync(); return((CounterView)result); } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
// Update Transaction Code public async Task <EntityView> Update(EntityUpdate update) { try { using (var db = new data.InvoiceContext()) { var result = await Update(db, update); await db.SaveChangesAsync(); return((EntityView)result); } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
public async Task <data.Invoice> Add(data.InvoiceContext db, InvoiceAdd add) { try { var newInvoice = new data.Invoice(); newInvoice.BillingAddress = add.BillingAddress; newInvoice.CreatedDate = add.CreatedDate; newInvoice.DueDate = add.DueDate; newInvoice.EmailTo = add.EmailTo; newInvoice.GrandTotal = add.GrandTotal; newInvoice.InvoiceEmailed = add.InvoiceEmailed; newInvoice.InvoiceNo = add.InvoiceNo; newInvoice.Notes = add.Notes; newInvoice.OrderedBy = add.OrderedBy; newInvoice.PaidAmount = add.PaidAmount; newInvoice.PaidDate = add.PaidDate; newInvoice.PaidTax = add.PaidTax; newInvoice.PaymentDetails = add.PaymentDetails; newInvoice.PurchaseOrderRef = add.PurchaseOrderRef; newInvoice.ShippingAddress = add.ShippingAddress; newInvoice.SubTotal = add.SubTotal; newInvoice.TaxTotal = add.TaxTotal; newInvoice.TermsAndConditions = add.TermsAndConditions; var customerLookup = await db.Customers.FirstOrDefaultAsync(w => w.CustomerId == add.CustomerCustomerId); if (customerLookup != null) { newInvoice.Customer = customerLookup; } db.Invoices.Add(newInvoice); return(newInvoice); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
public async Task <data.PaymentHistory> Add(data.InvoiceContext db, PaymentHistoryAdd add) { try { var newPaymentHistory = new data.PaymentHistory(); newPaymentHistory.Amount = add.Amount; newPaymentHistory.PaymentDate = add.PaymentDate; newPaymentHistory.Reference = add.Reference; var invoiceLookup = await db.Invoices.FirstOrDefaultAsync(w => w.InvoiceId == add.InvoiceInvoiceId); if (invoiceLookup != null) { newPaymentHistory.Invoice = invoiceLookup; } db.PaymentHistorys.Add(newPaymentHistory); return(newPaymentHistory); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
public async Task <data.Entity> Add(data.InvoiceContext db, EntityAdd add) { try { var newEntity = new data.Entity(); newEntity.Address = add.Address; newEntity.EntityExternalRef = add.EntityExternalRef; newEntity.LogoURL = add.LogoURL; newEntity.Name = add.Name; newEntity.SMTPEmailDisplayName = add.SMTPEmailDisplayName; newEntity.SMTPEmailFromAddress = add.SMTPEmailFromAddress; newEntity.SMTPHost = add.SMTPHost; newEntity.SMTPPassword = add.SMTPPassword; newEntity.SMTPUserName = add.SMTPUserName; db.Entitys.Add(newEntity); return(newEntity); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
public async Task <data.Customer> Update(data.InvoiceContext db, CustomerUpdate update) { try { var customerToUpdate = await db.Customers.FirstOrDefaultAsync(w => w.CustomerId == update.CustomerId); customerToUpdate.Active = update.Active; customerToUpdate.Address = update.Address; customerToUpdate.CustomerExteranlRef = update.CustomerExteranlRef; customerToUpdate.CustomerId = update.CustomerId; customerToUpdate.EmailAddress = update.EmailAddress; customerToUpdate.IsCompany = update.IsCompany; customerToUpdate.Name = update.Name; customerToUpdate.PhoneNumber = update.PhoneNumber; customerToUpdate.TaxNo = update.TaxNo; return(customerToUpdate); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
public async Task <data.Entity> Update(data.InvoiceContext db, EntityUpdate update) { try { var entityToUpdate = await db.Entitys.FirstOrDefaultAsync(w => w.EntityId == update.EntityId); entityToUpdate.Address = update.Address; entityToUpdate.EntityExternalRef = update.EntityExternalRef; entityToUpdate.EntityId = update.EntityId; entityToUpdate.LogoURL = update.LogoURL; entityToUpdate.Name = update.Name; entityToUpdate.SMTPEmailDisplayName = update.SMTPEmailDisplayName; entityToUpdate.SMTPEmailFromAddress = update.SMTPEmailFromAddress; entityToUpdate.SMTPHost = update.SMTPHost; entityToUpdate.SMTPPassword = update.SMTPPassword; entityToUpdate.SMTPUserName = update.SMTPUserName; return(entityToUpdate); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }
public async Task <data.InvoiceLine> Update(data.InvoiceContext db, InvoiceLineUpdate update) { try { var invoiceLineToUpdate = await db.InvoiceLines.FirstOrDefaultAsync(w => w.InvoiceLineId == update.InvoiceLineId); invoiceLineToUpdate.InvoiceLineId = update.InvoiceLineId; invoiceLineToUpdate.LineTotal = update.LineTotal; invoiceLineToUpdate.Notes = update.Notes; invoiceLineToUpdate.Product = update.Product; invoiceLineToUpdate.ProductCode = update.ProductCode; invoiceLineToUpdate.Quantity = update.Quantity; invoiceLineToUpdate.SubTotal = update.SubTotal; invoiceLineToUpdate.TaxExempt = update.TaxExempt; invoiceLineToUpdate.TaxTotal = update.TaxTotal; invoiceLineToUpdate.UnitCost = update.UnitCost; return(invoiceLineToUpdate); } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(null); } }