public List <ForumReportModel> GetReportsByComment(ForumReportComPage model) { List <ForumReportModel> list = new List <ForumReportModel>(); //Runs the stored procedure DataProvider.ExecuteCmd( "Forum_Reports_SelectByCommentId", inputParamMapper : delegate(SqlParameterCollection paramCol) { paramCol.AddWithValue("@CommentId", model.CommentId); paramCol.AddWithValue("@PageSize", model.PageSize); paramCol.AddWithValue("@PageNum", model.PageNum); }, singleRecordMapper : delegate(IDataReader reader, short set) { //Loops through the select, getting each report for a specific comment ForumReportModel report = new ForumReportModel(); int index = 0; report.Id = reader.GetSafeInt32(index++); report.FirstName = reader.GetSafeString(index++); report.LastName = reader.GetSafeString(index++); report.ReportText = reader.GetSafeString(index++); report.CreatedDate = reader.GetSafeDateTime(index++); list.Add(report); } ); return(list); }
public HttpResponseMessage GetReportsByComment(ForumReportComPage model) { try { if (ModelState.IsValid) { ItemsResponse <ForumReportModel> resp = new ItemsResponse <ForumReportModel>(); //Gets the reports for a specific comment resp.Items = _service.GetReportsByComment(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 getting reports by comment", ex); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }