Exemple #1
0
        protected dynamic GetViewJson(ViewType type, Id id)
        {
            var json = ReadViewJson(type, id, strict: false);

            if (json != null)
            {
                return(new Response
                {
                    StatusCode = HttpStatusCode.OK,
                    ContentType = MediaType.Json.ToString(),
                    Contents = body =>
                    {
                        using (var writer = new StreamWriter(body))
                        {
                            writer.Write(json);
                        }
                    }
                });
            }

            return(new Response
            {
                StatusCode = HttpStatusCode.NotFound,
                ReasonPhrase = "Failed to read " + type.ToText().WriteIf(id.IsAssigned, $"/{id}")
            });
        }
Exemple #2
0
        protected dynamic GetView(ViewType type, Id id)
        {
            var view = ReadView(type, id, strict: false);

            if (view != null)
            {
                return(view);
            }

            return(new Response
            {
                StatusCode = HttpStatusCode.NotFound,
                ReasonPhrase = "Failed to read " + type.ToText().WriteIf(id.IsAssigned, $"/{id}")
            });
        }