public void AppsDepleteSalesOrders(IDerivation derivation) { Extent <SalesOrderItem> salesOrderItems = this.Strategy.Session.Extent <SalesOrderItem>(); salesOrderItems.Filter.AddEquals(M.SalesOrderItem.SalesOrderItemState, new SalesOrderItemStates(this.Strategy.Session).InProcess); salesOrderItems.Filter.AddExists(M.OrderItem.DeliveryDate); salesOrderItems.AddSort(M.OrderItem.DeliveryDate, SortDirection.Descending); salesOrderItems = this.Strategy.Session.Instantiate(salesOrderItems); var subtract = this.PreviousQuantityOnHand - this.QuantityOnHand; foreach (SalesOrderItem salesOrderItem in salesOrderItems) { if (subtract > 0 && salesOrderItem.QuantityRequestsShipping > 0) { decimal diff; if (subtract >= salesOrderItem.QuantityRequestsShipping) { diff = salesOrderItem.QuantityRequestsShipping; } else { diff = subtract; } subtract -= diff; salesOrderItem.AppsOnDeriveSubtractFromShipping(derivation, diff); salesOrderItem.SalesOrderWhereSalesOrderItem.OnDerive(x => x.WithDerivation(derivation)); } } }
public Extent <Place> ExtentByPostalCode() { Extent <Place> places = this.Session.Extent <Place>(); places.AddSort(M.Place.PostalCode); return(places); }
public void AppsReplenishSalesOrders(IDerivation derivation) { Extent <SalesOrderItem> salesOrderItems = this.Strategy.Session.Extent <SalesOrderItem>(); salesOrderItems.Filter.AddEquals(M.SalesOrderItem.SalesOrderItemState, new SalesOrderItemStates(this.Strategy.Session).InProcess); salesOrderItems.AddSort(M.OrderItem.DeliveryDate, SortDirection.Ascending); var goods = this.Part is NonUnifiedPart nonUnifiedPart ? nonUnifiedPart.NonUnifiedGoodsWherePart : new [] { this.Part }; if (goods != null) { salesOrderItems.Filter.AddContainedIn(M.SalesOrderItem.Product, (Extent)goods); salesOrderItems = this.Strategy.Session.Instantiate(salesOrderItems); var extra = this.QuantityOnHand - this.PreviousQuantityOnHand; foreach (SalesOrderItem salesOrderItem in salesOrderItems) { if (extra > 0 && salesOrderItem.QuantityShortFalled > 0) { decimal diff; if (extra >= salesOrderItem.QuantityShortFalled) { diff = salesOrderItem.QuantityShortFalled; } else { diff = extra; } extra -= diff; salesOrderItem.AppsOnDeriveAddToShipping(derivation, diff); salesOrderItem.SalesOrderWhereSalesOrderItem.OnDerive(x => x.WithDerivation(derivation)); } } } }
public void UpgradeAssociation() { foreach (var init in this.Inits) { init(); this.Populate(); var acme = Company.Create(this.Session, "Acme", 2); var acne = Company.Create(this.Session, "Acne", 1); var john = Person.Create(this.Session, "John", 2); var jane = Person.Create(this.Session, "Jane", 1); var johny = Person.Create(this.Session, "johny", 4); var janet = Person.Create(this.Session, "Janet", 3); // Many 2 one acme.Manager = john; acne.Manager = john; Extent managedCompanies = john.CompaniesWhereManager; Assert.Equal(2, managedCompanies.Count); managedCompanies.Filter.AddLike(MetaNamed.Instance.Name, "%ne"); Assert.Single(managedCompanies); managedCompanies = john.CompaniesWhereManager; Assert.Equal(2, managedCompanies.Count); managedCompanies.AddSort(MetaNamed.Instance.Index, SortDirection.Descending); Assert.Equal(2, managedCompanies.Count); Assert.Equal(acme, managedCompanies[0]); Assert.Equal(acne, managedCompanies[1]); // Many to Many acme.AddOwner(john); acme.AddOwner(jane); acne.AddOwner(jane); acne.AddOwner(johny); Extent janesCompanies = jane.CompaniesWhereOwner; janesCompanies.Filter.AddLike(MetaNamed.Instance.Name, "%ne"); Assert.Single(janesCompanies); janesCompanies = jane.CompaniesWhereOwner; Assert.Equal(2, janesCompanies.Count); janesCompanies.AddSort(MetaNamed.Instance.Index); Assert.Equal(2, janesCompanies.Count); Assert.Equal(acne, janesCompanies[0]); Assert.Equal(acme, janesCompanies[1]); } }
public void UpgradeRole() { foreach (var init in this.Inits) { init(); this.Populate(); var acme = Company.Create(this.Session, "Acme"); var acne = Company.Create(this.Session, "Acne"); var john = Person.Create(this.Session, "John", 2); var jane = Person.Create(this.Session, "Jane", 1); var johny = Person.Create(this.Session, "Johny", 4); var janet = Person.Create(this.Session, "Janet", 3); // One 2 Many acme.AddEmployee(john); acme.AddEmployee(jane); acne.AddEmployee(johny); Extent employees = acme.Employees; Assert.Equal(2, employees.Count); employees.Filter.AddLike(MetaNamed.Instance.Name, "Ja%"); Assert.Single(employees); employees = acme.Employees; Assert.Equal(2, employees.Count); employees.AddSort(MetaNamed.Instance.Index, SortDirection.Descending); Assert.Equal(2, employees.Count); Assert.Equal(john, employees[0]); Assert.Equal(jane, employees[1]); // Many to Many acme.AddOwner(john); acme.AddOwner(jane); acne.AddOwner(jane); acne.AddOwner(johny); Extent acmeOwners = acme.Owners; Extent acneOwners = acme.Owners; acmeOwners.Filter.AddLike(MetaNamed.Instance.Name, "Ja%"); Assert.Single(acmeOwners); acmeOwners = acme.Owners; Assert.Equal(2, acmeOwners.Count); acmeOwners.AddSort(MetaNamed.Instance.Index); Assert.Equal(2, acmeOwners.Count); Assert.Equal(jane, acmeOwners[0]); Assert.Equal(john, acmeOwners[1]); } }