#pragma warning restore 612,618 public static (SalesOrderHeader, IContext) AddNewDetail( this SalesOrderHeader soh, Product product, [DefaultValue((short)1), Range(1, 999)] short quantity, IContext context ) { int stock = product.NumberInStock(); var sod = new SalesOrderDetail() { SalesOrderHeader = soh, SalesOrderID = soh.SalesOrderID, OrderQty = quantity, SpecialOfferProduct = Product_Functions.BestSpecialOfferProduct(product, quantity, context) }; //TODO: //sod.Recalculate(); return(soh, context.WithPendingSave(sod).WithWarnUser(stock < quantity ? $"Current inventory of {product} is {stock}" : "")); }
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); }
#pragma warning restore 612,618 public static (SalesOrderDetail, Action <IUserAdvisory>) AddNewDetail( this SalesOrderHeader soh, Product product, [DefaultValue((short)1), Range(1, 999)] short quantity, IQueryable <SpecialOfferProduct> sops ) { int stock = product.NumberInStock(); Action <IUserAdvisory> act = (IUserAdvisory ua) => ua.WarnUser( stock < quantity ? $"Current inventory of {product} is {stock}": ""); var sod = new SalesOrderDetail { SalesOrderHeader = soh, SalesOrderID = soh.SalesOrderID, OrderQty = quantity, SpecialOfferProduct = ProductFunctions2.BestSpecialOfferProduct(product, quantity, sops) }; //TODO: //sod.Recalculate(); return(sod, act); }
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; }