/// <summary> /// Gets the tax component. /// </summary> /// <returns>The tax component.</returns> public string GetTaxComponent() { if (this.taxComponent == null) { GetTaxComponentIndiaDataRequest getTaxComponentIndiaDataRequest = new GetTaxComponentIndiaDataRequest(this.Code, QueryResultSettings.SingleRecord); TaxComponentIndia taxComponentIndia = this.RequestContext.Runtime.Execute <SingleEntityDataServiceResponse <TaxComponentIndia> >(getTaxComponentIndiaDataRequest, this.RequestContext).Entity; if (taxComponentIndia == null) { throw new ArgumentException("{0} has no tax component defined", this.Code); } this.taxComponent = taxComponentIndia.TaxComponent; } return(this.taxComponent); }
/// <summary> /// Gets Tax component. /// </summary> /// <param name="request">The get tax component India data request.</param> /// <returns>Tax component.</returns> private SingleEntityDataServiceResponse <TaxComponentIndia> GetTaxComponentIndia(GetTaxComponentIndiaDataRequest request) { ThrowIf.Null(request, "request"); ThrowIf.NullOrWhiteSpace(request.TaxCode, "request.TaxCode"); bool found; bool updateL2Cache; IndiaTaxL2CacheDataStoreAccessor level2CacheDataAccessor = this.GetIndiaTaxL2CacheDataStoreAccessor(request.RequestContext); TaxComponentIndia result = DataManager.GetDataFromCache(() => level2CacheDataAccessor.GetTaxComponentIndia(request.TaxCode), out found, out updateL2Cache); if (!found) { var query = new SqlPagedQuery(request.QueryResultSettings) { From = TaxComponentTableIndiaViewName, Where = "TAXCODE = @id AND CHANNELID = @channelId", }; query.Parameters["@id"] = request.TaxCode; query.Parameters["@channelId"] = request.RequestContext.GetPrincipal().ChannelId; using (DatabaseContext databaseContext = new DatabaseContext(request.RequestContext)) { result = databaseContext.ReadEntity <TaxComponentIndia>(query).SingleOrDefault(); } updateL2Cache &= result != null; } if (updateL2Cache) { level2CacheDataAccessor.PutTaxComponentIndia(request.TaxCode, result); } return(new SingleEntityDataServiceResponse <TaxComponentIndia>(result)); }