Inheritance: ILiaraViewTemplate
Beispiel #1
0
        public override ILiaraViewTemplate ResolveView(ILiaraContext context)
        {
            var viewName = context.Response.Format.View;

            if (viewName == null)
            {
                if (context.Route != null)
                {
                    viewName = context.Route.Id.ToString();
                }
            }
            var result = new LiaraViewTemplate(viewName, null);

            if (service.HasTemplate(viewName))
            {
                return(result);
            }

            var templateString = ViewProvider.GetView(context);

            if (templateString == null)
            {
                context.Response.Status = LiaraHttpStatus.NoViewAssociated;
                return(ResolveInternalView(context));
            }

            service.GetTemplate(templateString, context.Response.Content, viewName);
            return(result);
        }
Beispiel #2
0
        public override ILiaraViewTemplate ResolveInternalView(ILiaraContext context)
        {
            if (context.Response.Status.Code != LiaraHttpStatus.OK.Code)
            {
                var viewName = "_liara_" + context.Response.Status.Code;
                var result   = new LiaraViewTemplate(viewName, null, true);
                if (service.HasTemplate(viewName))
                {
                    return(result);
                }

                var templateString = ViewProvider.GetInternalView(context);
                service.GetTemplate(templateString, new ErrorMessage(), viewName);
                return(result);
            }
            return(null);
        }