public void Delete(int ID) { using (var context = new InvoiceContext()) { var Invoice = context.Invoices.Find(ID); context.Invoices.Remove(Invoice); context.SaveChanges(); } }
public void Update(Invoice Invoice, int ID) { using (var context = new InvoiceContext()) { var InvoiceNew = context.Invoices.Find(ID); InvoiceNew.InvoiceNumber = Invoice.InvoiceNumber == null ? InvoiceNew.InvoiceNumber : Invoice.InvoiceNumber; context.SaveChanges(); } }
public void Insert(Detail Detail) { using (var context = new InvoiceContext()) { Detail.UserID = 1; context.Details.Add(Detail); context.SaveChanges(); } }
public void Delete(int id) { using (var context = new InvoiceContext()) { var userType = context.UserTypes.Find(id); context.UserTypes.Remove(userType); context.SaveChanges(); } }
public void Insert(Invoice Invoice) { using (var context = new InvoiceContext()) { Invoice.Date = DateTime.Today; context.Invoices.Add(Invoice); context.SaveChanges(); } }
public void Delete(int id) { using (var context = new InvoiceContext()) { var detail = context.Details.Find(id); context.Details.Remove(detail); context.SaveChanges(); } }
public void Update(UserType userType, int id) { using (var context = new InvoiceContext()) { var userTypeNew = context.UserTypes.Find(id); userTypeNew.UserTypeName = userType.UserTypeName == null ? userTypeNew.UserTypeName : userType.UserTypeName; context.SaveChanges(); } }
public void Insert(Invoice invoice) { using (var context = new InvoiceContext()) { invoice.Date = DateTime.Now; context.Invoices.Add(invoice); context.SaveChanges(); } }
public void Delete(int ID) { using (var context = new InvoiceContext()) { var Product = context.Products.Find(ID); context.Products.Remove(Product); context.SaveChanges(); } }
public MainVM(DbContextOptions <InvoiceContext> contextOptions) { context = new InvoiceContext(contextOptions); addCommand = new SimpleCommand(() => ExecuteOperation(Add)); deleteCommand = new SimpleCommand(() => ExecuteOperation(() => Delete(CurrentInvoice))); editCommand = new SimpleCommand(() => ExecuteOperation(() => Edit(CurrentInvoice))); filterCommand = new SimpleCommand(() => ExecuteOperation(Populate)); ExecuteOperation(Populate); // will update command state }
public Detail GetById(int ID) { Detail detail = null; using (var context = new InvoiceContext()) { detail = context.Details.Where(d => d.DetailID == ID).FirstOrDefault(); } return(detail); }
public List <Detail> Get() { List <Detail> details = null; using (var context = new InvoiceContext()) { details = context.Details.ToList(); } return(details); }
public UserType GetById(int id) { UserType userType = null; using (var context = new InvoiceContext()) { userType = context.UserTypes.Find(id); } return(userType); }
public List <UserType> Get() { List <UserType> userTypes = null; using (var context = new InvoiceContext()) { userTypes = context.UserTypes.ToList(); } return(userTypes); }
public void Insert(Detail detail) { using (var context = new InvoiceContext()) { // Falta insertar la cantidad de los productos yel precio total context.Details.Add(detail); context.SaveChanges(); } }
internal static FanAvaVerifyRequestModel CreateRefundRequest(InvoiceContext context, FanAvaCallbackResultModel callbackResult, FanAvaCheckResultModel checkResult) { return(new FanAvaVerifyRequestModel { WSContext = callbackResult.CallbackCheckData.WSContext, Token = callbackResult.CallbackCheckData.Token, Amount = checkResult.Amount, InvoiceNumber = callbackResult.InvoiceNumber }); }
public User GetById(int id) { User user = null; using (var context = new InvoiceContext()) { user = context.Users.Find(id); } return(user); }
public void CreateDatabaseTest() { var options = new DbContextOptionsBuilder() .UseSqlite("Data Source=Invoice.db") .Options; using var db = new InvoiceContext(options); db.Database.EnsureDeleted(); db.Database.EnsureCreated(); }
public List <Invoice> Get() { List <Invoice> Invoices = null; using (var context = new InvoiceContext()) { Invoices = context.Invoices.ToList(); } return(Invoices); }
public List <Product> Get() { List <Product> products = null; using (var context = new InvoiceContext()) { products = context.Products.Where(p => p.Enable == true).ToList(); } return(products); }
public void Update(Product Product, int ID) { using (var context = new InvoiceContext()) { var ProductNew = context.Products.Find(ID); ProductNew.ProductName = Product.ProductName == null ? ProductNew.ProductName : Product.ProductName; ProductNew.Prize = Product.Prize == 0 ? ProductNew.Prize : Product.Prize; context.SaveChanges(); } }
public Invoice GetById(int id) { Invoice invoice = null; using (var context = new InvoiceContext()) { invoice = context.Invoices.Find(id); } return(invoice); }
public List <Product> Get() { List <Product> Products = null; using (var context = new InvoiceContext()) { Products = context.Products.ToList(); } return(Products); }
public async Task <InvoiceView> CreateInvoice(UpdateInvoice updateInvoice) { try { var result = new InvoiceView(); using (var db = new InvoiceContext()) { if (db.Invoices.Any(w => w.InvoiceId == updateInvoice.InvoiceId)) { var invoice = db.Invoices.First(w => w.InvoiceId == updateInvoice.InvoiceId); invoice.BillngAddress = updateInvoice.BillngAddress; invoice.CreatedDate = updateInvoice.CreatedDate; invoice.DueDate = updateInvoice.DueDate; invoice.EmailTo = updateInvoice.EmailTo; invoice.GrandTotal = updateInvoice.GrandTotal; invoice.InvoiceEmailed = updateInvoice.InvoiceEmailed; invoice.InvoiceNo = updateInvoice.InvoiceNo; invoice.OrderedBy = updateInvoice.OrderedBy; invoice.PaidAmount = updateInvoice.PaidAmount; invoice.PaidDate = updateInvoice.PaidDate; invoice.PaidTax = updateInvoice.PaidTax; invoice.PaymentDetails = updateInvoice.PaymentDetails; invoice.PurchaseOrderRef = updateInvoice.PurchaseOrderRef; invoice.ShippingAddress = updateInvoice.ShippingAddress; invoice.SubTotal = updateInvoice.SubTotal; invoice.Tax = updateInvoice.Tax; invoice.TermsAndConditions = updateInvoice.TermsAndConditions; await db.SaveChangesAsync(); result.CreatedDate = invoice.CreatedDate; result.DueDate = invoice.DueDate; result.EmailTo = invoice.EmailTo; result.GrandTotal = invoice.GrandTotal; result.InvoiceEmailed = invoice.InvoiceEmailed; result.InvoiceId = invoice.InvoiceId; result.InvoiceNo = invoice.InvoiceNo; result.OrderedBy = invoice.OrderedBy; result.PaidAmount = invoice.PaidAmount; result.PaidDate = invoice.PaidDate; result.PaidTax = invoice.PaidTax; result.PaymentDetails = invoice.PaymentDetails; result.PurchaseOrderRef = invoice.PurchaseOrderRef; result.SubTotal = invoice.SubTotal; result.Tax = invoice.Tax; result.TermsAndConditions = invoice.TermsAndConditions; return(result); } } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); } return(null); }
public async Task <IInvoiceLineView> InvoiceLineCreate(IInvoiceLineCreate invoiceLineCreate) { try { var result = new InvoiceLineView(); using (var db = new InvoiceContext()) { var invoiceLine = new Database.InvoiceLine(); if (!db.Invoices.Any(w => w.InvoiceId == invoiceLineCreate.InvoiceId)) { return new InvoiceLineView() { __CQRSSuccessful = false, __CQRSErrorMessage = "Unable to find parent for Invoice", __CQRSStatusCode = 404 } } ; var invoice = db.Invoices.First(w => w.InvoiceId == invoiceLineCreate.InvoiceId); if (invoice.InvoiceLines == null) { invoice.InvoiceLines = new List <Database.InvoiceLine>(); } invoice.InvoiceLines.Add(invoiceLine); invoiceLine.Notes = invoiceLineCreate.Notes; invoiceLine.Product = invoiceLineCreate.Product; invoiceLine.ProductCode = invoiceLineCreate.ProductCode; invoiceLine.Quantity = invoiceLineCreate.Quantity; invoiceLine.SubTotal = invoiceLineCreate.SubTotal; invoiceLine.TaxExempt = invoiceLineCreate.TaxExempt; invoiceLine.TaxTotal = invoiceLineCreate.TaxTotal; invoiceLine.UnitCost = invoiceLineCreate.UnitCost; await db.SaveChangesAsync(); result.InvoiceLineId = invoiceLine.InvoiceLineId; result.LineTotal = invoiceLine.LineTotal; result.Notes = invoiceLine.Notes; result.Product = invoiceLine.Product; result.ProductCode = invoiceLine.ProductCode; result.Quantity = invoiceLine.Quantity; result.SubTotal = invoiceLine.SubTotal; result.TaxExempt = invoiceLine.TaxExempt; result.TaxTotal = invoiceLine.TaxTotal; result.UnitCost = invoiceLine.UnitCost; return(result); } } catch (Exception e) { LogFactory.GetLogger().Log(LogLevel.Error, e); return(new InvoiceLineView() { __CQRSSuccessful = false, __CQRSErrorMessage = "Unable to create InvoiceLineView", __CQRSStatusCode = 500 }); } }
public Product GetById(int ID) { Product product = null; using (var context = new InvoiceContext()) { product = context.Products.Where(p => p.Enable == true).FirstOrDefault(); } return(product); }
public void Update(Invoice invoice, int id) { using (var context = new InvoiceContext()) { var invoiceNew = context.Invoices.Find(id); invoiceNew.Date = invoice.Date == null ? invoice.Date : invoice.Date; invoiceNew.InvoiceNumber = invoice.InvoiceNumber == null ? invoice.InvoiceNumber : invoice.InvoiceNumber; context.SaveChanges(); } }
public string CreateInvoiceNumber(InvoiceContext context, string organisationId, bool taxInvoice, int year, int month) { var totalInvoice = context.Invoice.Where(u => u.IdNavigation.OrganisationId == organisationId && u.IdNavigation.IsTaxIncome == taxInvoice && u.IdNavigation.Date.Year == year).Count(); totalInvoice += 1; if (taxInvoice) { return($"{year:0000}-{month:00}-{totalInvoice:00000}"); } return($"N{year:0000}-{month:00}-{totalInvoice:00000}"); }
//public List<Product> Get(Product Product) //{ // List<Product> Products = null; // using (var context = new InvoiceContext()) // { // Products = context.Products. // Where(x => x.ProductName.Contains(Product.ProductName) // && x.ProductAddress.Contains(Product.ProductAddress)). // ToList(); // } // return Products; //} public Product GetById(int ID) { Product Product = null; using (var context = new InvoiceContext()) { Product = context.Products.Find(ID); } return(Product); }
protected void CleanupInvoiceContext() { var db = new InvoiceContext(); db.BatchInvoiceItems.RemoveRange(db.BatchInvoiceItems.ToArray()); db.InvoiceItems.RemoveRange(db.InvoiceItems.ToArray()); db.Invoices.RemoveRange(db.Invoices.ToArray()); db.Journals.RemoveRange(db.Journals.ToArray()); db.BatchInvoices.RemoveRange(db.BatchInvoices.ToArray()); db.SaveChanges(); }