Example #1
0
        public ForumReturnList GetByStatusId(ForumSelectModel model, int statusId)
        {
            //Dictionary used to insert data into a specific forum
            Dictionary <int, ForumModel> statusDict = new Dictionary <int, ForumModel>();
            ForumReturnList returnModel             = new ForumReturnList();

            returnModel.ForumList = new List <ForumModel>();
            //Runs stored proc selects all forums with a specific status id
            DataProvider.ExecuteCmd(
                "Forum_SelectByStatusId",
                inputParamMapper : delegate(SqlParameterCollection forumParamCol)
            {
                forumParamCol.AddWithValue("@StatusId", statusId);
                forumParamCol.AddWithValue("@PageSize", model.PageSize);
                forumParamCol.AddWithValue("@PageNum", model.PageNum);
                forumParamCol.AddWithValue("@NameFilter", model.NameFilter);
            },
                singleRecordMapper : delegate(IDataReader reader, short set)
            {
                //Switches between the different sql selects
                switch (set)
                {
                //Gets all the forums
                case 0:
                    ForumModel viewModel   = new ForumModel();
                    int index              = 0;
                    viewModel.Id           = reader.GetSafeInt32(index++);
                    viewModel.StatusId     = reader.GetSafeInt32(index++);
                    viewModel.ProjectId    = reader.GetSafeInt32(index++);
                    viewModel.Status       = reader.GetSafeString(index++);
                    viewModel.Name         = reader.GetSafeString(index++);
                    viewModel.Description  = reader.GetSafeString(index++);
                    viewModel.CreatedDate  = reader.GetSafeDateTime(index++);
                    viewModel.ModifiedDate = reader.GetSafeDateTime(index++);
                    viewModel.ModifiedBy   = reader.GetSafeString(index++);
                    returnModel.ForumList.Add(viewModel);
                    statusDict.Add(viewModel.Id, viewModel);
                    break;

                //Gets the total number of forums for this status
                case 1:
                    returnModel.ForumTotal = reader.GetSafeInt32(0);
                    break;

                //Gets the total number of comments for each forum
                case 2:
                    int indexx = 0;
                    int sId    = reader.GetSafeInt32(indexx++);
                    int total  = reader.GetSafeInt32(indexx);
                    statusDict[sId].TotalComments = total;
                    break;
                }
            }
                );
            return(returnModel);
        }
Example #2
0
        public ForumReturnList GetAllForums(ForumSelectModel model)
        {
            ForumReturnList returnModel = new ForumReturnList();

            returnModel.ForumList = new List <ForumModel>();
            //Runs the stored proc to get all the forums
            DataProvider.ExecuteCmd(
                "Forum_SelectAll",
                inputParamMapper : delegate(SqlParameterCollection paramCol)
            {
                paramCol.AddWithValue("@PageSize", model.PageSize);
                paramCol.AddWithValue("@PageNum", model.PageNum);
                paramCol.AddWithValue("@NameFilter", model.NameFilter);
            },
                singleRecordMapper : delegate(IDataReader reader, short set)
            {
                switch (set)
                {
                //Gets the list of forums
                case 0:
                    ForumModel viewModel = new ForumModel();
                    {
                        int index              = 0;
                        viewModel.Id           = reader.GetSafeInt32(index++);
                        viewModel.StatusId     = reader.GetSafeInt32(index++);
                        viewModel.ProjectId    = reader.GetSafeInt32(index++);
                        viewModel.Status       = reader.GetSafeString(index++);
                        viewModel.Name         = reader.GetSafeString(index++);
                        viewModel.Description  = reader.GetSafeString(index++);
                        viewModel.CreatedDate  = reader.GetSafeDateTime(index++);
                        viewModel.ModifiedDate = reader.GetSafeDateTime(index++);
                        viewModel.ModifiedBy   = reader.GetSafeString(index++);
                        returnModel.ForumList.Add(viewModel);
                    }
                    break;

                //Gets the total amount of forums
                case 1:
                    returnModel.ForumTotal = reader.GetSafeInt32(0);
                    break;
                }
            }
                );
            return(returnModel);
        }