public void LineItemFactoryCanGetSeveralLineItemsFromDatabase() { LineItemFactory factory = new LineItemFactory(); List <LineItem> lineItems = factory.getAll(); Assert.NotEmpty(lineItems); Assert.True(lineItems.Count() > 1); foreach (LineItem lineItem in lineItems) { Assert.NotNull(lineItem.CustomerOderId); Assert.NotNull(lineItem.ProductId); } }
/// <summary> /// The get line item collection. /// </summary> /// <param name="invoiceKey"> /// The invoice key. /// </param> /// <returns> /// The <see cref="LineItemCollection"/>. /// </returns> private LineItemCollection GetLineItemCollection(Guid invoiceKey) { var sql = new Sql(); sql.Select("*").From <InvoiceItemDto>(SqlSyntax).Where <InvoiceItemDto>(x => x.ContainerKey == invoiceKey); var dtos = Database.Fetch <InvoiceItemDto>(sql); var factory = new LineItemFactory(); var collection = new LineItemCollection(); foreach (var dto in dtos) { collection.Add(factory.BuildEntity(dto)); } return(collection); }
public static List <LineItem> GetAllLineItems(List <CustomerOrder> COL) { List <LineItem> LIL = new List <LineItem>(); LineItemFactory LIF = new LineItemFactory(); List <LineItem> AllLineItems = LIF.getAll(); foreach (CustomerOrder co in COL) { List <LineItem> lineItemsInOrder = ( from li in AllLineItems where li.CustomerOderId == co.CustomerOrderId select li ).ToList(); if (lineItemsInOrder.Count > 0) { LIL.AddRange(lineItemsInOrder); } } return(LIL); }
private LineItemCollection GetLineItemCollection(Guid itemCacheKey) { var sql = new Sql(); sql.Select("*") .From <ItemCacheItemDto>() .Where <ItemCacheItemDto>(x => x.ContainerKey == itemCacheKey); var dtos = Database.Fetch <ItemCacheItemDto>(sql); //var lineItems = _lineItemRepository.GetByContainerId(itemCacheId); var factory = new LineItemFactory(); var collection = new LineItemCollection(); foreach (var dto in dtos) { collection.Add(factory.BuildEntity(dto)); } return(collection); }
public void LineItemFactoryCanBeCreated() { var lineItemFactory = new LineItemFactory(); Assert.NotNull(lineItemFactory); }