protected override async Task RenderBody(IResponseContext rsp)
        {
            rsp.Write("<div class=\"container body-content\">");
            rsp.Write("<div class=\"clearfix\"></div>");

            _logger.Info($"Returning user '{rsp.PathArgs[0]}' messages {rsp.Page}, {rsp.Size}");

            var page = await _gbProvider.GetUserMessages(rsp.PathArgs[0], rsp.Page, rsp.Size).ConfigureAwait(false);

            if (page.Items == null)
            {
                rsp.Write($"<p>User '{HtmlResponse.HtmlEncode(rsp.PathArgs[0])}' not found</p>");
            }
            else if (!page.Items.Any())
            {
                rsp.Write("<p>No messages</p>");
            }
            else
            {
                foreach (var m in page.Items)
                {
                    rsp.Write("<hr/><div class=\"row\">");
                    rsp.Write($"<div class=\"col-md-2\"><b>{m.Created.ToString("G")}</b></div>");
                    rsp.Write("</div>");

                    rsp.Write("<div class=\"row\">");
                    rsp.Write($"<div class=\"col-md-12\">{HtmlResponse.HtmlEncode(m.Text)}</div>");
                    rsp.Write("</div>");
                }
            }
            rsp.Write("<div>");
        }
        protected override async Task RenderBody(IResponseContext rsp)
        {
            rsp.Write("<div class=\"container body-content\">");
            rsp.Write("<div class=\"clearfix\"></div>");

            _logger.Info($"Listing users {rsp.Page}, {rsp.Size}");

            var page = await _gbProvider.GetUsers(rsp.Page, rsp.Size).ConfigureAwait(false);

            if (!page.Items.Any())
            {
                rsp.Write("<p>No users found</p>");
            }
            else
            {
                foreach (var u in page.Items)
                {
                    rsp.Write($"<hr/><div class=\"row\" data-id=\"{HtmlResponse.HtmlEncode(u.UserLogin)}\">");
                    rsp.Write($"<div class=\"col-md-1\"><b>{u.UserLogin}</b></div>");
                    rsp.Write($"<div class=\"col-md-4\">{HtmlResponse.HtmlEncode(u.DisplayName)}</div>");
                    rsp.Write("</div>");
                }
            }
            rsp.Write("<div>");
        }
Exemple #3
0
        protected override async Task RenderBody(IResponseContext rsp)
        {
            rsp.Write("<div class=\"container body-content\">");
            rsp.Write("<div class=\"clearfix\"></div>");

            _logger.Info($"Deleting user: {rsp.PathArgs[0]}");

            var count = await _gbProvider.RemoveUser(rsp.PathArgs[0]).ConfigureAwait(false);

            if (count > 0)
            {
                rsp.Write($"<p>User '{HtmlResponse.HtmlEncode(rsp.PathArgs[0])}' deleted</p>");
            }
            else
            {
                rsp.Write($"<p>User '{HtmlResponse.HtmlEncode(rsp.PathArgs[0])}' not found</p>");
                rsp.Status = StatusCodes.BadRequest;
            }

            rsp.Write("<div>");
        }
Exemple #4
0
        protected override async Task RenderBody(IResponseContext rsp)
        {
            rsp.Write("<div class=\"container body-content\">");
            rsp.Write("<div class=\"clearfix\"></div>");

            var page = await _gbProvider.GetUsers(1, -1).ConfigureAwait(false);

            _logger.Info("Returning all the Gusrst Book");

            if (!page.Items.Any())
            {
                rsp.Write("<p>No users found</p>");
            }
            else
            {
                foreach (var u in page.Items)
                {
                    rsp.Write($"<hr/><div class=\"row\" data-id=\"{HtmlResponse.HtmlEncode(u.UserLogin)}\">");
                    rsp.Write($"<div class=\"col-md-1\"><b>{u.UserLogin}</b></div>");
                    rsp.Write($"<div class=\"col-md-4\">{HtmlResponse.HtmlEncode(u.DisplayName)}</div>");
                    rsp.Write("</div>");

                    var msgPage = await _gbProvider.GetUserMessages(u.UserLogin, 1, -1).ConfigureAwait(false);

                    foreach (var m in msgPage.Items)
                    {
                        rsp.Write("<div class=\"row\">");
                        rsp.Write("<div class=\"col-md-1\">&nbsp;</div>");
                        rsp.Write($"<div class=\"col-md-2\"><b>{m.Created.ToString("G")}</b></div>");
                        rsp.Write("</div>");

                        rsp.Write("<div class=\"row\">");
                        rsp.Write($"<div class=\"col-md-12\">{HtmlResponse.HtmlEncode(m.Text)}</div>");
                        rsp.Write("</div>");
                    }
                    rsp.Write("<div class=\"clearfix\"></div>");
                }
            }
            rsp.Write("<div>");
        }