示例#1
0
文件: Product.cs 项目: HedinRakot/KVS
        /// <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;
        }
示例#2
0
		private void attach_Product(Product entity)
		{
			this.SendPropertyChanging();
			entity.OrderType = this;
		}
示例#3
0
		private void detach_Product(Product entity)
		{
			this.SendPropertyChanging();
			entity.RegistrationOrderType = null;
		}
示例#4
0
 partial void DeleteProduct(Product instance);
示例#5
0
 partial void UpdateProduct(Product instance);
示例#6
0
 partial void InsertProduct(Product instance);
示例#7
0
		private void detach_Product(Product entity)
		{
			this.SendPropertyChanging();
			entity.ProductCategory = null;
		}
示例#8
0
		private void attach_Product(Product entity)
		{
			this.SendPropertyChanging();
			entity.ProductCategory = this;
		}