// Api lấy danh sách chỉ tiêu nhóm gộp cùng api lấy chi tiết chỉ tiêu nhóm public object GetTeamTargetList(GetTeamTargetListInput input) { try { DynamicParameters param = new DynamicParameters(); String sql = "Select ID, YEAR, NAME_CAMPAIGN_CATEGORY, TEAM_NAME, MONTH_1, MONTH_2, MONTH_3, MONTH_4, MONTH_5, MONTH_6, MONTH_7, MONTH_8, MONTH_9 ,MONTH_10 ,MONTH_11 ,MONTH_12, TOTAL, CAMPAIGN_CATEGORY_ID, TEAM_ID from vwTEAM_TARGET_List WHERE 1 = 1 "; String conditionSql = ""; String countSql = "Select count(*) from vwTEAM_TARGET_List WHERE 1 = 1"; if (!string.IsNullOrEmpty(input.CAMPAIGN_CATEGORY_ID)) { conditionSql += " and CAMPAIGN_CATEGORY_ID = @CAMPAIGN_CATEGORY_ID"; param.Add("@CAMPAIGN_CATEGORY_ID", input.CAMPAIGN_CATEGORY_ID); } if (!string.IsNullOrEmpty(input.NAME_CAMPAIGN_CATEGORY)) { conditionSql += " and NAME_CAMPAIGN_CATEGORY = @NAME_CAMPAIGN_CATEGORY"; param.Add("@NAME_CAMPAIGN_CATEGORY", input.NAME_CAMPAIGN_CATEGORY); } if (!string.IsNullOrEmpty(input.TEAM_ID)) { conditionSql += " and TEAM_ID = @TEAM_ID"; param.Add("@TEAM_ID", input.TEAM_ID); } if (!string.IsNullOrEmpty(input.TEAM_NAME)) { conditionSql += " and TEAM_NAME = @TEAM_NAME"; param.Add("@TEAM_NAME", input.TEAM_NAME); } sql += conditionSql; sql += " ORDER BY " + (!string.IsNullOrEmpty(input.ORDERBY) ? input.ORDERBY : " YEAR DESC"); countSql += conditionSql; int total = DapperORM.Count(countSql, param); sql += " OFFSET @OFFSET ROWS " + " FETCH NEXT @SIZE ROWS ONLY"; param.Add("@OFFSET", (input.PAGE - 1) * input.SIZE); param.Add("@SIZE", input.SIZE); var callCategories = DapperORM.ExcecuteReturnList <TeamTargetList>(sql, param); Pagination pagination = new Pagination(input.PAGE, input.SIZE, total); return(new { data = callCategories, pagination = pagination }); } catch (Exception ex) { return(new { data = new { Message = ex.Message, ErrorCode = 500 } }); } }
public IActionResult GetTeamTargetList(GetTeamTargetListInput input) { return(Ok(_teamTargetRepository.GetTeamTargetList(input))); }