public static KidResource FromData(Kid data, bool includeRelated = false) { var resource = new KidResource { Id = data.Id, Name = data.Name, Balance = data.Balance, CabinId = data.CabinId }; if (includeRelated) { resource.Cabin = CabinResource.FromData(data.Cabin); resource.Transactions = data.Transactions.Select(t => new TransactionResource { Id = t.Id, Type = t.Type, Amount = t.Amount, UserName = t.UserName, TimeStamp = t.TimeStamp }).ToList(); } return(resource); }
public static CabinResource FromData(Cabin data, bool includeRelated = false) { var resource = new CabinResource { Id = data.Id, Name = data.Name }; if (includeRelated) { resource.Kids = data.Kids.Select(k => KidResource.FromData(k)).ToList(); } return(resource); }