protected override async Task RenderBody(IResponseContext rsp) { rsp.Write("<div class=\"container body-content\">"); rsp.Write("<div class=\"clearfix\"></div>"); var p = rsp.GetPostParameters(); string login, text; p.TryGetValue("login", out login); p.TryGetValue("msgtext", out text); _logger.Info($"Adding message: {login}, {text}"); if (string.IsNullOrEmpty(login)) { rsp.Status = StatusCodes.BadRequest; rsp.Write("<p>User login should not be empty</p>"); } else { var ui = await _gbProvider.AddMessage(login, text); rsp.Status = StatusCodes.Created; rsp.Write($"<p>User '{ui.UserLogin}' added message</p>"); } rsp.Write("<div>"); }
protected override async Task RenderBody(IResponseContext rsp) { rsp.Write("<div class=\"container body-content\">"); rsp.Write("<div class=\"clearfix\"></div>"); var p = rsp.GetPostParameters(); string login, dispName; p.TryGetValue("login", out login); p.TryGetValue("displayname", out dispName); _logger.Info($"Adding user: {login}, {dispName}"); if (string.IsNullOrEmpty(login)) { rsp.Status = StatusCodes.BadRequest; rsp.Write("<p>User login should not be empty</p>"); } else { var ui = await _gbProvider.AddUser(login, dispName); rsp.Status = StatusCodes.Created; rsp.AddLink(Path + "/" + WebUtility.UrlDecode(login)); rsp.Write($"<p>User '{ui.UserLogin}' created</p>"); } 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("Clearing the Guest Book"); await _gbProvider.Clear().ConfigureAwait(false); rsp.Write($"<p>The book cleared</p>"); 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>"); }
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>"); }
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>"); }
public void ProcessResult(IRequestContext request, IResponseContext response) { var fullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FilePath); if (!File.Exists(fullPath)) { throw new FileNotFoundException(String.Format("The view at {0} could not be found", fullPath)); } response.ContentType = "text/html"; response.Write(File.ReadAllText(fullPath)); }
public void ProcessResult(IRequestContext request, IResponseContext response) { response.ContentType = "application/xml"; var result = new StringBuilder(); using (var writer = new StringWriter(result)) { new XmlSerializer(Data.GetType()).Serialize(writer, Data); } response.Write(result.ToString()); }
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>"); }
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>"); 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\"> </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>"); }
public void ProcessResult(IRequestContext request, IResponseContext response) { response.ContentType = "text/html"; response.Write(Data); }
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\"> </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>"); }
public void ProcessResult(IRequestContext request, IResponseContext response) { response.ContentType = "text/html"; response.Write(File.ReadAllText(_filepath)); }
public void ProcessResult(IRequestContext request, IResponseContext response) { response.ContentType = "application/json"; response.Write(new JavaScriptSerializer().Serialize(Data)); }
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>"); }