public IActionResult GetContractBillingList([FromBody] ContractBillingExportToExcelSearchViewModel model) { model.SellerID = CurrentUserDetails.SellerID; var contractBillingList = ReportService.DatatableContractBilling(model); return(Ok(contractBillingList)); }
//public ReportHeaderViewModel GetReportFor(string ContractNumer, int SellerID) //{ // var sqlStr = new StringBuilder(); // sqlStr.AppendFormat(@" // SELECT org1.OrganizationName AS AgencyName,org2.OrganizationName AS AdvertiserName FROM dbo.bsContract // LEFT JOIN dbo.Organization org1 ON org1.OrganizationID = bsContract.AgencyOrgID // LEFT JOIN dbo.Organization org2 ON org2.OrganizationID = bsContract.AdvertiserID // WHERE ContractNumber=@ContractNumber AND bsContract.SellerID=@SellerID // "); // var parameters = new DynamicParameters(); // parameters.Add("ContractNumber", ContractNumer); // parameters.Add("SellerID", SellerID); // return _dapperRepository.ExecuteQueryFirstOrDefault<string>(sqlStr.ToString(), parameters); //} public DataTable DatatableContractBilling(ContractBillingExportToExcelSearchViewModel model) { string reportTypeForSp = ""; string reportTypeSelect = ""; string status = string.Join(",", model.Status); if (model.ReportType == "LineItem") { reportTypeForSp = " ,[Line Item], Market ,[Description] ,[Vendor Unit ID] ,[Vendor Name],[Start Date] ,[End Date], "; model.ReportParameters = "[Line Item], Market ,[Description] ,[Vendor Unit ID] ,[Vendor Name],[Start Date] ,[End Date]"; reportTypeSelect = " ,[Line Item], Market ,[Description] ,[Vendor Unit ID] ,[Vendor Name], CONVERT(VARCHAR(8),[Start Date],1) AS [Start Date] ,CONVERT(VARCHAR(8),[End Date],1) AS [End Date], "; } if (model.ReportType == "Vendor") { reportTypeForSp = " ,[Vendor Name], "; model.ReportParameters = "[Vendor Name]"; reportTypeSelect = " ,[Vendor Name], "; } if (model.ReportType == "Market") { reportTypeForSp = " ,Market, "; model.ReportParameters = "Market"; reportTypeSelect = " ,Market, "; } if (model.ReportType == "Contract" || model.BillingReportType == "SummaryReport") { reportTypeForSp = " , "; model.ReportParameters = ""; reportTypeSelect = " , "; } StringBuilder strSQL = new StringBuilder(); if (model.BillingReportType == "DetailReport") { strSQL.AppendFormat(@"stp_GetContractBillingDetailReportEquinoxByUsingPivot"); } if (model.BillingReportType == "SummaryReport") { strSQL.AppendFormat(@"stp_GetContractBillingSummaryReportEquinoxByUsingPivot"); } SqlParameter[] _parameters = new SqlParameter[15]; _parameters[0] = new SqlParameter("@PeriodStart", model.FromDate); _parameters[1] = new SqlParameter("@PeriodEnd", model.ToDate); _parameters[2] = new SqlParameter("@EnteredSince", model.EnteredSince); _parameters[3] = new SqlParameter("@RevisedSince", model.RevisedSince); _parameters[4] = new SqlParameter("@SellerID", model.SellerID); _parameters[5] = new SqlParameter("@AccountExecutive", model.AccountExecutive); _parameters[6] = new SqlParameter("@AcountCoordinator", model.AccountCoordinator); _parameters[7] = new SqlParameter("@Advertiser", model.Advertiser); _parameters[8] = new SqlParameter("@Agency", model.AgencyName); _parameters[9] = new SqlParameter("@Status", status); _parameters[10] = new SqlParameter("@CheckProrate", model.ProRate); _parameters[11] = new SqlParameter("@ContractNumber", model.ContractNumber); _parameters[12] = new SqlParameter("@ReportType", reportTypeForSp); _parameters[13] = new SqlParameter("@ReportParaMeters", model.ReportParameters); _parameters[14] = new SqlParameter("@ReportTypeSelect", reportTypeSelect); DataTable dt = _dapperRepository.ExecuteDataTableProc(strSQL.ToString(), _parameters); // var list = dt.Select().ToList(); return(dt); }