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>"); 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>"); }