示例#1
0
        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);
        }
示例#2
0
        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);
        }