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); }
public static TransactionResource FromData(Transaction data, bool includeRelated = false) { var resource = new TransactionResource { Id = data.Id, Type = data.Type, Amount = data.Amount, TimeStamp = data.TimeStamp, UserName = data.UserName }; if (includeRelated) { resource.Kid = KidResource.FromData(data.Kid); } return(resource); }