Esempio n. 1
0
        public async Task <IList <ReportHeaderViewModel> > getReportHeaderForWorkOrder(string ContractNumber, string ReportFor, int SellerID)
        {
            var strSql = new StringBuilder();

            strSql.AppendFormat(@"SELECT DISTINCT COALESCE(ISNULL(FirstName,'') + ' ' + LastName,'') AS Name,Contact.EmailAddress,JobName,org1.OrganizationName AS AgencyName,org2.OrganizationName AS AdvertiserName FROM dbo.bsContractLineItemV2 
                                    LEFT JOIN dbo.bsContract ON bsContract.ContractNumber = bsContractLineItemV2.ContractNumber
                                    LEFT JOIN dbo.Organization org1 ON org1.OrganizationID = bsContract.AgencyOrgID
                                    LEFT JOIN dbo.Organization org2 ON org2.OrganizationID = bsContract.AdvertiserID
                                    LEFT JOIN Contact ON Contact.ContactID = bsContract.ACID
                                    WHERE bsContract.ContractNumber=@ContractNumber AND bsContract.SellerID=@SellerID ");


            //if (ReportFor == "Vendor" || ReportFor == "Media Owner")
            //{
            //    strSql.Append(@"AND bsContractLineItemV2.LineItemStyle='Associated'");
            //}
            //if (ReportFor == "Media Owner")
            //{
            //    strSql.Append(@"AND bsContractLineItemV2.LineItemStyle<>'Associated'");
            //}

            var parameterlist = new DynamicParameters();

            parameterlist.Add("@ContractNumber", ContractNumber);
            parameterlist.Add("@SellerID", SellerID);
            var result = await _dapperRepository.ExecuteQueryAsync <ReportHeaderViewModel>(strSql.ToString(), parameterlist);

            return(result.ToList());
        }