Esempio n. 1
0
        public ForumReportsCommentsList GetReportTotals(ForumReportPageModel model)
        {
            ForumReportsCommentsList returnModel = new ForumReportsCommentsList();

            returnModel.List = new List <ForumReportCommentModel>();
            //Runs the stored procedure
            DataProvider.ExecuteCmd(
                "Forum_Reports_SelectAll",
                inputParamMapper : delegate(SqlParameterCollection paramCol)
            {
                paramCol.AddWithValue("@PageSize", model.PageSize);
                paramCol.AddWithValue("@PageNum", model.PageNum);
            },
                singleRecordMapper : delegate(IDataReader reader, short set)
            {
                //Switches between the sql select statements
                switch (set)
                {
                //Gets the list of reported comments
                case 0:
                    ForumReportCommentModel comment = new ForumReportCommentModel();
                    int index         = 0;
                    comment.CommentId = reader.GetSafeInt32(index++);
                    comment.ForumId   = reader.GetSafeInt32(index++);
                    comment.Text      = reader.GetSafeString(index++);
                    comment.Total     = reader.GetSafeInt32(index++);
                    returnModel.List.Add(comment);
                    break;

                //Gets the total list of reported comments
                case 1:
                    returnModel.Total = reader.GetSafeInt32(0);
                    break;
                }
            }
                );
            return(returnModel);
        }
Esempio n. 2
0
 public HttpResponseMessage GetReports(ForumReportPageModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ItemResponse <ForumReportsCommentsList> resp = new ItemResponse <ForumReportsCommentsList>();
             //Gets all the top level reports
             resp.Item = _service.GetReportTotals(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 reported comments", ex);
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }