private SendFeedbackModel BindSendFeedbackModel() { var model = new SendFeedbackModel { Comment = HttpContext.Current.Request.Form["comment"] }; if (string.IsNullOrWhiteSpace(model.Comment)) { ModelState.AddModelError("comment", "'Comment' is required"); } var files = HttpContext.Current.Request.Files; if (files.Count > 1) { ModelState.AddModelError("file", "Only one file is allowed"); } else if (files.Count == 1) { model.File = files[0]; } return(model); }
private static string GenerateBody(AppUser user, SendFeedbackModel model, string name, string url) { var body = $"Username: {HttpUtility.HtmlEncode(user.UserName)}<br />"; body += $"E-mail: {HttpUtility.HtmlEncode(user.Email)}<br />"; body += $"User Id: {HttpUtility.HtmlEncode(user.Id)}<br />"; body += $"UTC Time: {DateTime.UtcNow}<br />"; if (model.File == null) { body += "Attachment: No<br />"; } else { body += $"Attachment: {HttpUtility.HtmlEncode(model.File.FileName)}<br />"; body += $"Blob name: {HttpUtility.HtmlEncode(name)}<br />"; body += $"Blob url: {HttpUtility.HtmlEncode(url)}<br />"; } body += "Comment:<br />"; body += HttpUtility.HtmlEncode(model.Comment)?.Replace("\r\n", "<br />"); return(body); }