public CommunitySingleState Create(community model)
        {
            var community = new CommunitySingleState
            {
                id             = model.id,
                name           = model.name,
                local          = model.local,
                description    = model.description,
                avatar         = model.avatar,
                foundationDate = model.foundationDate.Value,

                events   = [email protected] <@event, EventsCollectionState>(i => eventFactory.Create(i)),
                notices  = model.notice.Select <notice, NoticesCollectionState>(i => noticeFactory.Create(i)),
                admins   = model.admins.Select <userInfo, UsersCollectionState>(i => userFactory.Create(i)),
                members  = model.members.Select <userInfo, UsersCollectionState>(i => userFactory.Create(i)),
                comments = model.comment.Select <comment, CommentsCollectionState>(i => commentFactory.Create(i)),
                tags     = model.tag.Select <tag, string>(i => i.name),
                _Links   = new CommunitySingleState.Link()
            };

            //Add hyperMedia
            community._Links.Self         = _links.Self(model.id);
            community._Links.Events       = _links.Events(model.id);
            community._Links.PastEvents   = _links.PastEvents(model.id);
            community._Links.FutureEvents = _links.FutureEvents(model.id);
            community._Links.Members      = _links.Members(model.id);
            community._Links.Admins       = _links.Admins(model.id);
            community._Links.Notices      = _links.Notices(model.id);
            community._Links.Comments     = _links.Comments(model.id);


            return(community);
        }
Пример #2
0
        public CommunitiesCollectionState Create(community model)
        {
            var community = new CommunitiesCollectionState
            {
                id             = model.id,
                name           = model.name,
                local          = model.local,
                description    = model.description,
                avatar         = model.avatar,
                foundationDate = model.foundationDate.Value,
                _Links         = new LinkCollection()
            };

            //Add hyperMedia
            community._Links.self = _links.Self(model.id);
            return(community);
        }