Ejemplo n.º 1
0
        public List<TpTreaty> GetTpTreaty(string hostCountryCode, string searchQuery)
        {
            if (!string.IsNullOrEmpty(searchQuery))
            {
                return GetTpTreatyByArticleContentSearch(hostCountryCode, searchQuery.Trim());
            }
            using (var work = new UnitOfWork())
            {

                var allTpTreaties = new List<TpTreaty>();
                var tpTreaties = new TpTreatyRepository(work).GetTpTreaty(hostCountryCode, searchQuery).ToList();
                var distinctConceptIds = tpTreaties.Select(b => b.OcdeArt1_ConceptId).Distinct()
                                                   .Union(tpTreaties.Select(b => b.OcdeArt2_ConceptId).Distinct())
                                                   .Union(tpTreaties.Select(b => b.OcdeArt3_ConceptId).Distinct())
                                                   .Union(tpTreaties.Select(b => b.CompetentAuthority_ConceptId).Distinct())
                                                   .Union(tpTreaties.Select(b => b.ReliefFromDouble_ConceptId).Distinct())
                                                   .Where(b => b!= null).Select(b => b);

                var conceptIds = string.Join(",", distinctConceptIds);
                var partnerCountryCodes = string.Join(",", tpTreaties.Select(b => b.Country1.Code).ToList());
                var articles = new TreetyBusiness().GetArticlesByHostCountry(hostCountryCode, partnerCountryCodes, conceptIds);
                var treatyBusiness = new TreetyBusiness();
                foreach (var treaty in tpTreaties)
                {
                    var countryPair = treatyBusiness.GetPairCountryCode(hostCountryCode, treaty.Country1.Code);
                    allTpTreaties.Add(new TpTreaty()
                                          {
                                                Id = treaty.Id,
                                                OcdeArt1 = !string.IsNullOrEmpty(treaty.OcdeArt1) ? treaty.OcdeArt1 : string.Empty,
                                                OcdeArt2 = !string.IsNullOrEmpty(treaty.OcdeArt2) ? treaty.OcdeArt2 : string.Empty,
                                                TreatyPartnerCountry = treaty.Country1.Name,
                                                TreatyPartnerCountryCode = treaty.Country1.Code,
                                                CompetentAuthority = !string.IsNullOrEmpty(treaty.CompetentAuthority) ? treaty.CompetentAuthority : string.Empty,
                                                ReliefFromDouble = !string.IsNullOrEmpty(treaty.ReliefFromDouble) ? treaty.ReliefFromDouble : string.Empty,
                                                OcdeArt1ConceptId = treaty.OcdeArt1_ConceptId,
                                                OcdeArt2ConceptId = treaty.OcdeArt2_ConceptId,
                                                ReliefFromDoubleConceptId = treaty.ReliefFromDouble_ConceptId,
                                                CompetentAuthorityConceptId = treaty.CompetentAuthority_ConceptId,
                                                OcdeArt3 = treaty.OcdeArt3,
                                                OcdeArt3ConceptId = treaty.OcdeArt3_ConceptId,
                                                IsContentAvailbleForCompetentAuthority = articles.Count(b => (b.HostCountryCode == countryPair[0] && b.PartnerCountryCode == countryPair[1])
                                                                                                              && b.ConceptId == treaty.CompetentAuthority_ConceptId && b.ArticleContent.Length > 0) > 0,
                                                IsContentAvailbleForReliefFromDouble = articles.Count(b => (b.HostCountryCode == countryPair[0] && b.PartnerCountryCode == countryPair[1])
                                                                                                              && b.ConceptId == treaty.ReliefFromDouble_ConceptId && b.ArticleContent.Length > 0) > 0,
                                                IsContentAvailbleForOcdeArt3 = articles.Count(b => (b.HostCountryCode == countryPair[0] && b.PartnerCountryCode == countryPair[1])
                                                                                                              && b.ConceptId == treaty.OcdeArt3_ConceptId && b.ArticleContent.Length > 0) > 0,
                                                IsContentAvailbleForOcdeArt2 = articles.Count(b => (b.HostCountryCode == countryPair[0] && b.PartnerCountryCode == countryPair[1])
                                                                                                              && b.ConceptId == treaty.OcdeArt2_ConceptId && b.ArticleContent.Length > 0) > 0,
                                                IsContentAvailbleForOcdeArt1 = articles.Count(b => (b.HostCountryCode == countryPair[0] && b.PartnerCountryCode == countryPair[1])
                                                                                                              && b.ConceptId == treaty.OcdeArt1_ConceptId && b.ArticleContent.Length > 0) > 0
                                          });

                }

                allTpTreaties = allTpTreaties.OrderBy(a => a.TreatyPartnerCountry).ToList();
                return allTpTreaties;
            }
        }
Ejemplo n.º 2
0
        public List<TreatyWithWTRRates> GetTreatyWithWTRRates(string hostCountryCode)
        {
            using (var work = new UnitOfWork())
            {
                var treatyMetadata = new TreatyRepository(work).GetTreaty(hostCountryCode, "").ToList();
                var treatyBusiness = new TreetyBusiness();
                var conceptIds = "DIV_10" + "," + "INT_11" + "," + "ROY_12";
                var partnerCountryCodes = string.Join(",", treatyMetadata.Select(b => b.Country1.Code).ToList());
                var partnerCountryCodes2 = string.Join(",", treatyMetadata.Select(b => b.Country.Code).ToList());
                partnerCountryCodes = partnerCountryCodes + "," + partnerCountryCodes2;
                var articles = new TreetyBusiness().GetArticlesByHostCountry(hostCountryCode, partnerCountryCodes, conceptIds);
                List<TreatyWithWTRRates> listWTRRates = new List<TreatyWithWTRRates>();
                foreach (var treetyMD in treatyMetadata)
                {
                    var list = new WTRateRepository(work).GetAllWTRatesValue(treetyMD.HostCountryId, treetyMD.PartnerCountryId);
                    if (list.Count == 0) list = new WTRateRepository(work).GetAllWTRatesValue(treetyMD.PartnerCountryId, treetyMD.HostCountryId);
                    var divStreamId = ConfigurationManager.AppSettings["DivSubstantialHoldingRateStreamId"].Trim();
                    var divportfolioStreamId = ConfigurationManager.AppSettings["DIVPortfolioStreamId"].Trim();
                    var intGeneralStreamId = ConfigurationManager.AppSettings["IntGeneralStreamId"].Trim();
                    var intCbStreamId = ConfigurationManager.AppSettings["InterestCBRateStreamId"].Trim();
                    var intBankStreamId = ConfigurationManager.AppSettings["InterestBankRateStreamId"].Trim();
                    var royPatentStreamId = ConfigurationManager.AppSettings["RoyalityPatentRateStreamId"].Trim();
                    var royTmStreamId = ConfigurationManager.AppSettings["RoyalityTmRateStreamId"].Trim();
                    var royCrStreamId = ConfigurationManager.AppSettings["RoyalityCrRateStreamId"].Trim();
                    var royLpStreamId = ConfigurationManager.AppSettings["RoyalityLpRateStreamId"].Trim();

                    var divValue = list.Where(b => b.StreamId.Equals(divStreamId)).FirstOrDefault();
                    var divportfolioRatevalue = list.Where(b => b.StreamId.Equals(divportfolioStreamId)).FirstOrDefault();
                    var intGeneralValue = list.Where(b => b.StreamId.Equals(intGeneralStreamId)).FirstOrDefault();
                    var intCbValue = list.Where(b => b.StreamId.Equals(intCbStreamId)).FirstOrDefault();
                    var intBankValue = list.Where(b => b.StreamId.Equals(intBankStreamId)).FirstOrDefault();
                    var royPatentValue = list.Where(b => b.StreamId.Equals(royPatentStreamId)).FirstOrDefault();
                    var royTmValue = list.Where(b => b.StreamId.Equals(royTmStreamId)).FirstOrDefault();
                    var royLpValue = list.Where(b => b.StreamId.Equals(royLpStreamId)).FirstOrDefault();
                    var royCrValue = list.Where(b => b.StreamId.Equals(royCrStreamId)).FirstOrDefault();

                    var countryPair = treatyBusiness.GetPairCountryCode(treetyMD.Country.Code, treetyMD.Country1.Code);
                    var partnerCountryName = treetyMD.Country1.Code == hostCountryCode ? treetyMD.Country.Name : treetyMD.Country1.Name;
                    var partnerCountryId = treetyMD.Country1.Code == hostCountryCode ? treetyMD.Country.Id : treetyMD.Country1.Id;
                    TreatyWithWTRRates trWithWTR = new TreatyWithWTRRates()
                          {
                              DivSubstantialHoldingRate = divValue == null ? "" : divValue.Rate,
                              DivPortfolioRate = divportfolioRatevalue == null ? "" : divportfolioRatevalue.Rate,
                              InterestGeneralRate = intGeneralValue == null ? "" : intGeneralValue.Rate,
                              InterestCbRate = intCbValue == null ? "" : intCbValue.Rate,
                              InterestBankRate = intBankValue == null ? "" : intBankValue.Rate,
                              RoyaltyPatentRate = royPatentValue == null ? "" : royPatentValue.Rate,
                              RoyaltyCrRate = royCrValue == null ? "" : royCrValue.Rate,
                              RoyaltyLpRate = royLpValue == null ? "" : royLpValue.Rate,
                              RoyaltyTmRate = royTmValue == null ? "" : royTmValue.Rate,
                              DivSubstantialHoldingRateArticleLine = divValue == null ? "" : divValue.ArticleLine,
                              DivportfolioRateArticleLine = divportfolioRatevalue == null ? "" : divportfolioRatevalue.ArticleLine,
                              InterestGeneralRateArticleLine = intGeneralValue == null ? "" : intGeneralValue.ArticleLine,
                              InterestBankRateArticleLine = intBankValue == null ? "" : intBankValue.ArticleLine,
                              InterestCbRateArticleLine = intCbValue == null ? "" : intCbValue.ArticleLine,
                              RoyaltyPatentRateArticleLine = royPatentValue == null ? "" : royPatentValue.ArticleLine,
                              RoyaltyCrRateArticleLine = royCrValue == null ? "" : royCrValue.ArticleLine,
                              RoyaltyLpRateArticleLine = royLpValue == null ? "" : royLpValue.ArticleLine,
                              RoyaltyTmRateArticleLine = royTmValue == null ? "" : royTmValue.ArticleLine,
                              Country = partnerCountryName,
                              CountryId = partnerCountryId,
                              CountryCode = countryPair[0].Equals(hostCountryCode) ? countryPair[1] : countryPair[0],
                              EffectiveDate = treetyMD.EffectiveDate,
                              EntryIntoForce = treetyMD.EntryIntoForce,
                              Id = treetyMD.Id,
                              IsContentAvailable = (treetyMD.TreatyPdf != null && treetyMD.TreatyPdf.Length > 0),
                              Status = treetyMD.Status,
                              Title = treetyMD.Title,
                              IsContentAvailableForDividendRate = articles.Count(b => (b.HostCountryCode == countryPair[0] && b.PartnerCountryCode == countryPair[1])
                                                                                                            && b.ConceptId == "DIV_10" && b.ArticleContent.Length > 0) > 0,
                              IsContentAvailableForInterestRate = articles.Count(b => (b.HostCountryCode == countryPair[0] && b.PartnerCountryCode == countryPair[1])
                                                                                                            && b.ConceptId == "INT_11" && b.ArticleContent.Length > 0) > 0,
                              IsContentAvailableForRoyaltyRate = articles.Count(b => (b.HostCountryCode == countryPair[0] && b.PartnerCountryCode == countryPair[1])
                                                                                                            && b.ConceptId == "ROY_12" && b.ArticleContent.Length > 0) > 0,
                          };
                    listWTRRates.Add(trWithWTR);
                }
                listWTRRates = listWTRRates.OrderBy(b => b.Country).ToList();
                var singleDomesticItem = GetsingleDomesticRate(hostCountryCode);
                listWTRRates.Insert(0, singleDomesticItem);
                return listWTRRates;
            }
        }