/// <summary> /// Erstellt ein neues Produkt. /// </summary> /// <param name="name">Name des Produkts.</param> /// <param name="productCategoryId">Id der Produktkategorie, falls gewünscht.</param> /// <param name="priceAmount">Standardpreis des Produkts.</param> /// <param name="authorativeCharge">Standardmäßge behördliche Gebühr, falls gewünscht.</param> /// <param name="itemNumber">Artikelnummer des Produkts.</param> /// <param name="needsVAT">Gibt an, ob das Produkt mehrwertsteuerpflichtig ist oder nicht.</param> /// <param name="orderTypeId">Id der Auftragsart.</param> /// <param name="registrationOrderTypeId">Id der Zulassungsauftragsart, falls benötigt.</param> /// <param name="dbContext">Datenbankkontext für die Transaktion.</param> /// <returns>Das neue Produkt.</returns> public static Product CreateProduct(string name, int? productCategoryId, decimal priceAmount, decimal? authorativeCharge, string itemNumber, int orderTypeId, int? registrationOrderTypeId, bool needsVAT, DataClasses1DataContext dbContext) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("Der Name darf nicht leer sein."); } if (string.IsNullOrEmpty(itemNumber)) { throw new ArgumentException("Die Artikelnummer darf nicht leer sein."); } var product = new Product() { Name = name, ProductCategoryId = productCategoryId, ItemNumber = itemNumber, OrderTypeId = orderTypeId, RegistrationOrderTypeId = registrationOrderTypeId, NeedsVAT = needsVAT, IsLocked = false, _dbContext = dbContext }; var price = new Price() { Amount = priceAmount, AuthorativeCharge = authorativeCharge, }; product.Price.Add(price); dbContext.Product.InsertOnSubmit(product); dbContext.SubmitChanges(); dbContext.WriteLogItem("Produkt " + name + " wurde angelegt.", LogTypes.INSERT, product.Id, "Product"); return product; }
private void attach_Product(Product entity) { this.SendPropertyChanging(); entity.OrderType = this; }
private void detach_Product(Product entity) { this.SendPropertyChanging(); entity.RegistrationOrderType = null; }
partial void DeleteProduct(Product instance);
partial void UpdateProduct(Product instance);
partial void InsertProduct(Product instance);
private void detach_Product(Product entity) { this.SendPropertyChanging(); entity.ProductCategory = null; }
private void attach_Product(Product entity) { this.SendPropertyChanging(); entity.ProductCategory = this; }