public static ApiList FromList(ShoppingList dataList) { var list = new ApiList() { Id = dataList.Id, Name = dataList.Name, Family = dataList.Family.Id }; if (dataList.Items != null) { list.Items = dataList.Items.Select(i => ApiListItem.FromItem(i)).ToArray(); } return(list); }
public static ApiListItem FromItem(ListItem dataItem) { var item = new ApiListItem() { Id = dataItem.Id, Name = dataItem.Product.Name, List = dataItem.List.Id, Quantity = dataItem.Quantity, Units = dataItem.Product.Units }; if (dataItem.Variants != null) { item.Variants = dataItem.Variants.Select(i => i.Id).ToArray(); } return(item); }