示例#1
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;
            }
        }
示例#2
0
        public Response<List<Treaty>> GetTreaty(string hostCountryCode, string searchInput)
        {
            try
            {
                using (var work = new UnitOfWork())
                {
                    var treatyMetadata = new TreatyRepository(work).GetTreaty(hostCountryCode, searchInput).ToList();

                    var responseData = treatyMetadata.Select(b => new Treaty()
                    {
                        Country = b.Country1.Name,
                        CountryId = b.Country1.Id,
                        CountryCode = b.Country1.Code,
                        EffectiveDate = b.EffectiveDate,
                        EntryIntoForce = b.EntryIntoForce,
                        Id = b.Id,
                        IsContentAvailable = (b.TreatyPdf != null && b.TreatyPdf.Length > 0),
                        Status = b.Status,
                        Title = b.Title
                    }).ToList();

                    var response = new Response<List<Treaty>>();
                    response.Data = responseData;
                    response.Success = true;
                    return response;
                }
            }
            catch (Exception ex)
            {
                return new Response<List<Treaty>> { Data = new List<Treaty>(), Success = false, ErrorMessage = "An error occured!" };
            }
        }