public static OrderResultModel FromOrder(Order order, IEnumerable <AlipayUser> users) { var result = new OrderResultModel() { OrderId = order.OrderId, ShopId = order.ShopId, State = order.State, ProductList = order.OrderItems?.Select(x => OrderItemResultModel.FromOrderItem(x, users)).ToList() ?? new List <OrderItemResultModel>(), CreatedAt = order.CreatedAt, CreatedBy = order.CreatedBy, OwnerName = users.FirstOrDefault(x => x.Id == order.CreatedBy)?.AlipayName }; return(result); }
public static OrderItemResultModel FromOrderItem(OrderItem iten, IEnumerable <AlipayUser> users) { var result = new OrderItemResultModel() { OrderItemId = iten.OrderItemId, ProductId = iten.ProductId, Name = iten.Name, Price = iten.Price, Remark = iten.Remark, Options = iten.OrderItemOptions?.Select(OrderItemOptionsResultModel.FromOrderItenOption).ToList() ?? new List <OrderItemOptionsResultModel>(), CreatedAt = iten.CreatedAt, OwnerId = iten.CreatedBy, OwnerAvatar = users.FirstOrDefault(x => x.Id == iten.CreatedBy)?.AlipayPhoto, OwnerName = users.FirstOrDefault(x => x.Id == iten.CreatedBy)?.AlipayName }; return(result); }