示例#1
0
 public static SaleModel From(Sale value)
 {
     return new SaleModel
       {
     Id = value.Id,
     CompanyName = value.Company.Name,
     Date = value.Date.ToString(Constants.DATE_FORMAT),
     Value = value.Items.Select(it => it.Quantity * it.Price).Sum().Formatted(),
     Items = value.Items.Select(SaleItemModel.From).ToList(),
       };
 }
示例#2
0
 /// <summary>
 ///   Fixes the ProductId on the items (this is done by SaveChanges in normal execution)
 /// </summary>
 private static void FixItems(Sale sale)
 {
     foreach (var item in sale.Items)
     item.ProductId = item.Product.Id;
 }