public void RemoveLineItem(LineItem li) { if (LineItems != null) { LineItems.Remove(li); } }
/// <summary> /// Add InvoiceLine By InvoiceLine /// </summary> /// <param name="invoiceLine"></param> /// <returns></returns> public bool AddInvoiceLine(InvoiceLine invoiceLine) { if (invoiceLine == null) { //empty item new LogManager().Log($"Fail to add invoice line (NULL) to invoice(Id: {InvoiceNumber})"); return(false); } if (LineItems == null) { LineItems = new List <InvoiceLine>(); } if (!LineItems.Any(i => i.InvoiceLineId == invoiceLine.InvoiceLineId)) { //add LineItems.Add(invoiceLine); new LogManager().Log($"Add invoice line (Id: {invoiceLine.InvoiceLineId}) to invoice (Id: {InvoiceNumber})"); return(true); } else { //update var existingItem = LineItems.Where(i => i.InvoiceLineId == invoiceLine.InvoiceLineId).First(); LineItems.Remove(existingItem); LineItems.Add(invoiceLine); new LogManager().Log($"Update invoice line (Id: {invoiceLine.InvoiceLineId}) to invoice (Id: {InvoiceNumber})"); return(false); } }
public void RemoveProduct(int productId) { var item = LineItems.FirstOrDefault(x => x.ProductId == productId); if (item != null) { LineItems.Remove(item); } }
public void Remove(string lineItemId) { var lineItem = LineItems.FirstOrDefault(li => li.Id == lineItemId); if (lineItem != null) { LineItems.Remove(lineItem); } }
public Result RemoveInvoiceLine(int invoiceLineId) { var result = ValidInput2(invoiceLineId); if (result.Success) { var lineItemToRemove = LineItems.Single(i => i.InvoiceLineId == invoiceLineId); LineItems.Remove(lineItemToRemove); } return(result); }
public void RemoveProduct(int productId) { var item = LineItems.FirstOrDefault(x => x.ProductId == productId); if (item != null) { LineItems.Remove(item); } /* veya */ /*foreach (var item in LineItems) * { * if (item.ProductId == productId) * { * LineItems.Remove(item); * break; * } * }*/ }
public void RemoveLineItem(int id) { LineItems.Remove(LineItems.Where(li => li.Id == id).Single()); }