/// <summary> /// Deprecated Method for adding a new object to the Invoices EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToInvoices(Invoice invoice) { base.AddObject("Invoices", invoice); }
/// <summary> /// Create a new Invoice object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="date">Initial value of the Date property.</param> /// <param name="type">Initial value of the Type property.</param> /// <param name="supplierID">Initial value of the SupplierID property.</param> /// <param name="recipientID">Initial value of the RecipientID property.</param> /// <param name="number">Initial value of the Number property.</param> /// <param name="userID">Initial value of the UserID property.</param> public static Invoice CreateInvoice(global::System.Int32 id, global::System.DateTime date, global::System.String type, global::System.Int32 supplierID, global::System.Int32 recipientID, global::System.Int32 number, global::System.Int32 userID) { Invoice invoice = new Invoice(); invoice.ID = id; invoice.Date = date; invoice.Type = type; invoice.SupplierID = supplierID; invoice.RecipientID = recipientID; invoice.Number = number; invoice.UserID = userID; return invoice; }
public static void SaveInvoice(InvoiceModel invoiceModel) { if (UserHelper.UserID != null) { var storageDbEntities = new StorageDBEntities(); Invoice invoice = new Invoice { SupplierID = invoiceModel.Supplier.ID, RecipientID = invoiceModel.Recipient.ID, Date = invoiceModel.Date, Type = invoiceModel.Type, Number = invoiceModel.Number, PriceType = invoiceModel.PriceType, UserID = UserHelper.UserID.Value }; foreach (ProductsInInvoiceModel productsInInvoiceModel in invoiceModel.Products.Where(p => p.ProductID > 0).ToList()) { ProductsInInvoice productsInInvoice = new ProductsInInvoice { Price = productsInInvoiceModel.Price, Quantity = productsInInvoiceModel.Quantity, ProductID = productsInInvoiceModel.ProductID }; invoice.ProductsInInvoices.Add(productsInInvoice); } storageDbEntities.Invoices.AddObject(invoice); storageDbEntities.SaveChanges(); } }