예제 #1
0
        private Entity RenderForm(HttpContext httpContext, object feature, Entity entity)
        {
            var type = feature.GetType();

            var req = httpContext.Request;

            var actions   = RenderActions(httpContext, feature).ToArray();
            var entitites =
                from action in actions
                select new Entity
            {
                Class      = KnownClasses.Row,
                Rel        = KnownRelations.Row,
                Title      = action.Title,
                Properties = PropertyCollection.Create(new
                {
                    action.Title,
                    Description = $"Ação {action.Title} disponível para {entity.Title}"
                }),
                Actions = new EntityActionCollection(action)
            };

            var self = httpContext.Request.GetRequestUri();

            entity.Class      = $"{KnownClasses.Rows}, feature";
            entity.Title      = GetName(type).ChangeCase(TextCase.ProperCase);
            entity.Links      = new LinkCollection().AddSelf(self);
            entity.Properties = PropertyCollection.Create(new
            {
                entity.Title,
                Description = $"Ações disponíveis para {entity.Title}."
            });
            entity.Entities = new EntityCollection(entitites);
            entity.Actions  = new EntityActionCollection(actions);

            return(entity);
        }