public int ReportComment(ForumReportAddRequest model) { int id = 0; //Runs the stored procedure to report a forum comment DataProvider.ExecuteNonQuery( "Forum_Reports_Insert", inputParamMapper : delegate(SqlParameterCollection paramCol) { SqlParameter param = new SqlParameter(); param.ParameterName = "@Id"; param.SqlDbType = SqlDbType.Int; param.Direction = ParameterDirection.Output; paramCol.Add(param); paramCol.AddWithValue("@CommentId", model.CommentId); paramCol.AddWithValue("@PersonId", model.ReporterId); paramCol.AddWithValue("@ReportText", model.ReportText); paramCol.AddWithValue("@CreatedBy", model.CreatedBy); }, returnParameters : delegate(SqlParameterCollection paramCol) { id = (int)paramCol["@Id"].Value; } ); return(id); }
public HttpResponseMessage ReportComment(ForumReportAddRequest model) { try { if (ModelState.IsValid) { //Gets the current user from the cookie var user = _principal.Identity.GetCurrentUser(); model.ReporterId = user.Id; model.CreatedBy = user.Name; //Filters the report text to censor any curse words model.ReportText = _profService.Cleanse(model.ReportText); ItemResponse <int> resp = new ItemResponse <int>(); //Sends the report to the database resp.Item = _service.ReportComment(model); return(Request.CreateResponse(HttpStatusCode.OK, resp)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { //Log any exception that occurs log.Error("Error reporting comment", ex); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }