public SalesOrderDetail AddNewDetail(Product product, [DefaultValue((short)1), Range(1, 999)] short quantity) { int stock = product.NumberInStock(); if (stock < quantity) { var t = Container.NewTitleBuilder(); t.Append("Current inventory of").Append(product).Append(" is").Append(stock); Container.WarnUser(t.ToString()); } var sod = Container.NewTransientInstance <SalesOrderDetail>(); sod.SalesOrderHeader = this; sod.SalesOrderID = SalesOrderID; sod.OrderQty = quantity; sod.SpecialOfferProduct = product.BestSpecialOfferProduct(quantity); sod.Recalculate(); return(sod); }
public SalesOrderDetail AddNewDetail(Product product, [DefaultValue((short) 1), Range(1, 999)] short quantity) { int stock = product.NumberInStock(); if (stock < quantity) { var t = Container.NewTitleBuilder(); t.Append("Current inventory of").Append(product).Append(" is").Append(stock); Container.WarnUser(t.ToString()); } var sod = Container.NewTransientInstance<SalesOrderDetail>(); sod.SalesOrderHeader = this; sod.SalesOrderID = SalesOrderID; sod.OrderQty = quantity; sod.SpecialOfferProduct = product.BestSpecialOfferProduct(quantity); sod.Recalculate(); return sod; }