예제 #1
0
        public async void Given_PutIsNotOK_When_Configure_Then_ReturnFalse()
        {
            //Arrange
            var mockHttpRequestFactory = new Mock <IHttpRequestFactory>();

            mockHttpRequestFactory.Setup(x => x.Put(
                                             It.IsAny <string>(), It.IsAny <object>(), It.IsAny <string>()
                                             ))
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.NotFound
            });

            var mockOptions = new Mock <IOptions <ApiSettings> >();

            mockOptions.SetupGet(x => x.Value).Returns(new ApiSettings());

            var sut = new CountryApi(
                mockHttpRequestFactory.Object,
                mockOptions.Object
                );

            //Act
            var result = await sut.Configure(null, null);

            //Assert
            result.Should().BeFalse();
        }
예제 #2
0
        public override void MakeMove(GameApi api)
        {
            IEnumerable <CountryApi> countries = api.Countries;
            CountryApi myCountry = api.Country;

            foreach (CountryApi c in countries)
            {
                myCountry.TryDeclareWar(this, c);
            }

            IEnumerable <ArmyApi> armies = api.Country.Armies;

            foreach (ArmyApi a in armies)
            {
                if (a.MovingDirection == Direction.None)
                {
                    if (a.IsArmyMovePossible(this, Direction.East))
                    {
                        a.TrySendArmy(this, Direction.East);
                    }
                    else if (a.IsArmyMovePossible(this, Direction.North))
                    {
                        a.TrySendArmy(this, Direction.North);
                    }
                    else if (a.IsArmyMovePossible(this, Direction.West))
                    {
                        a.TrySendArmy(this, Direction.West);
                    }
                    else if (a.IsArmyMovePossible(this, Direction.South))
                    {
                        a.TrySendArmy(this, Direction.South);
                    }
                }
            }
        }
예제 #3
0
        public void Given_GetIsNotOK_When_GetCountries_Then_CountriesNotFoundExceptionIsThrown()
        {
            //Arrange
            var mockHttpRequestFactory = new Mock <IHttpRequestFactory>();

            mockHttpRequestFactory.Setup(x => x.Get(
                                             It.IsAny <string>(), It.IsAny <string>()
                                             ))
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.NotFound
            });

            var mockOptions = new Mock <IOptions <ApiSettings> >();

            mockOptions.SetupGet(x => x.Value).Returns(new ApiSettings());

            var sut = new CountryApi(
                mockHttpRequestFactory.Object,
                mockOptions.Object
                );

            //Act
            Func <Task> func = async() => await sut.GetCountries();

            //Assert
            func.Should().Throw <CountriesNotFoundException>();
        }
        private bool IsValidCountry(string country)
        {
            var result = CountryApi.GetCountriesByName(country);

            if (result != null)
            {
                return(true);
            }
            return(false);
        }
예제 #5
0
        public IActionResult GetCountries()
        {
            var countries = CountryApi.GetCountries();

            if (countries == null)
            {
                return(NotFound());
            }

            return(Ok(countries));
        }
        public void Countries_WhenDoesntSuppliedCredentials_ReturnsCountries(WireDataFormat format)
        {
            //arrange
            var client           = TestContext.CreateClientNoCredentials(format);
            var countryResources = new CountryApi(client.HttpChannel);

            //act
            var result = countryResources.Countries();

            //assert
            CollectionAssert.IsNotEmpty(result);
        }
        public void Countries_WhenDoesntSuppliedCredentials_ReturnsCountries(WireDataFormat format)
        {
            //arrange 
            var client = TestContext.CreateClientNoCredentials(format);
            var countryResources = new CountryApi(client.HttpChannel);

            //act
            var result = countryResources.Countries();

            //assert
            CollectionAssert.IsNotEmpty(result);
        }
 private static bool CountryTest(Iatec.Adems.PeopleManagement.Client.Configuration apiConfig)
 {
     try
     {
         var countryApi = new CountryApi(apiConfig);
         var country    = countryApi.GetCurrent();
         return(true);
     }
     catch (ApiException)
     {
         throw;
     }
 }
 private static bool CountryTest(Iatec.Adems.PeopleManagement.Client.Configuration apiConfig)
 {
     try
     {
         var countryApi = new CountryApi(apiConfig);
         var country    = countryApi.GetPageAvailable(20, 0, "teste", new List <Guid> {
             Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()
         });
         return(true);
     }
     catch (ApiException)
     {
         throw;
     }
 }
예제 #10
0
        public async void Given_GetIsOK_When_GetCountries_Then_ReturnList()
        {
            //Arrange
            var list = new List <CountryDto>
            {
                new CountryDto
                {
                    Name = "England"
                },
                new CountryDto
                {
                    Name = "Ireland"
                },
                new CountryDto
                {
                    Name = "Spain"
                }
            };

            var mockHttpRequestFactory = new Mock <IHttpRequestFactory>();

            mockHttpRequestFactory.Setup(x => x.Get(
                                             It.IsAny <string>(), It.IsAny <string>()
                                             ))
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new JsonContent(list)
            });

            var mockOptions = new Mock <IOptions <ApiSettings> >();

            mockOptions.SetupGet(x => x.Value).Returns(new ApiSettings());

            var sut = new CountryApi(
                mockHttpRequestFactory.Object,
                mockOptions.Object
                );

            //Act
            var result = await sut.GetCountries();

            //Assert
            result.Should().NotBeNull();
            result.ToList().Count().Should().Be(3);
        }
예제 #11
0
        public async void ListCountries_ReturnsCountries()
        {
            //Arrange
            var mockLogger             = new Mock <ILogger <CountryApi> >();
            var mockHttpRequestFactory = new Mock <IHttpRequestFactory>();

            mockHttpRequestFactory.Setup(x => x.Get(
                                             It.IsAny <string>(), It.IsAny <Dictionary <string, string> >(), It.IsAny <string>()
                                             )
                                         )
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new JsonContent(new ListCountriesResponse
                {
                    Countries = new List <Country>
                    {
                        new Country {
                            Name = "United Status"
                        },
                        new Country {
                            Name = "United Kingdom"
                        }
                    }
                })
            });

            var baseAddress = "BaseAddress";

            var sut = new CountryApi(
                mockLogger.Object,
                mockHttpRequestFactory.Object,
                baseAddress
                );

            //Act
            var response = await sut.ListCountriesAsync();

            //Assert
            mockHttpRequestFactory.Verify(x => x.Get(It.IsAny <string>(), It.IsAny <Dictionary <string, string> >(), It.IsAny <string>()));
            response.Countries[0].Name.Should().Be("United Status");
            response.Countries[1].Name.Should().Be("United Kingdom");
        }
 public CountryApiTests()
 {
     instance = new CountryApi();
 }
예제 #13
0
 public void Init()
 {
     instance = new CountryApi();
 }
예제 #14
0
    protected override void Page_Load(object sender, System.EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!Ektron.Cms.DataIO.LicenseManager.LicenseManager.IsFeatureEnable(m_refContentApi.RequestInformationRef, Ektron.Cms.DataIO.LicenseManager.Feature.eCommerce))
        {
            Utilities.ShowError(m_refContentApi.EkMsgRef.GetMessage("feature locked error"));
        }
        RegisterResource();
        if (!Utilities.ValidateUserLogin())
        {
            return;
        }
        Util_CheckAccess();

        if (!string.IsNullOrEmpty(Page.Request.QueryString["search"]))
        {
            searchCriteria = Page.Request.QueryString["search"];
        }
        if (!string.IsNullOrEmpty(Page.Request.QueryString["country"]))
        {
            countryId = Convert.ToInt64(Page.Request.QueryString["country"]);
        }

        try
        {

            m_refRegion = new RegionApi();
            m_refCountry = new CountryApi();
            criteria.PagingInfo = new PagingInfo(10000);
            criteria.AddFilter(CountryProperty.IsEnabled, Ektron.Cms.Common.CriteriaFilterOperator.EqualTo, true);
            if (countryId > 0)
            {
                criteria.AddFilter(CountryProperty.Id, Ektron.Cms.Common.CriteriaFilterOperator.EqualTo, countryId);
            }

            hdnCurrentPage.Value = CurrentPage.Text;
            switch (this.m_sPageAction)
            {
                case "addedit":
                    CountryList = m_refCountry.GetList(criteria);
                    if (Page.IsPostBack)
                    {
                        Process_AddEdit();
                    }
                    else
                    {
                        Display_AddEdit();
                    }
                    break;
                case "del":
                    Process_Delete();
                    break;
                case "view":
                    CountryList = m_refCountry.GetList(criteria);
                    Display_View();
                    break;
                default:
                    CountryList = m_refCountry.GetList(criteria);
                    if (Page.IsPostBack == false)
                    {
                        Display_All();
                    }
                    break;
            }
            Util_SetLabels();
            Util_SetJS();

        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("unique key") > -1)
            {
                Utilities.ShowError(GetMessage("lbl region dupe"));
            }
            else
            {
                Utilities.ShowError(ex.Message);
            }
        }
    }
예제 #15
0
    protected override void Page_Load(object sender, System.EventArgs e)
    {
        base.Page_Load(sender, e);
        RegisterResources();
        if (!Ektron.Cms.DataIO.LicenseManager.LicenseManager.IsFeatureEnable(m_refContentApi.RequestInformationRef, Ektron.Cms.DataIO.LicenseManager.Feature.eCommerce))
        {
            Utilities.ShowError(m_refContentApi.EkMsgRef.GetMessage("feature locked error"));
        }
        if (!Utilities.ValidateUserLogin())
        {
            return;
        }
        AppPath = m_refContentApi.AppPath;
        CommerceLibrary.CheckCommerceAdminAccess();

        if (!string.IsNullOrEmpty(Page.Request.QueryString["sort"]))
        {
            sortCriteria = Page.Request.QueryString["sort"];
        }
        if (!string.IsNullOrEmpty(Page.Request.QueryString["search"]))
        {
            searchCriteria = Page.Request.QueryString["search"];
        }
        m_refCountry = new CountryApi();
        hdnCurrentPage.Value = CurrentPage.Text;
        try
        {
            switch (this.m_sPageAction)
            {
                case "addedit":
                    if (Page.IsPostBack)
                    {
                        Process_AddEdit();
                    }
                    else
                    {
                        Display_AddEdit();
                    }
                    break;
                case "del":
                    Process_Delete();
                    break;
                case "view":
                    Display_View();
                    break;
                default:
                    if (Page.IsPostBack == false)
                    {
                        Display_All();
                    }
                    break;
            }
            Util_SetLabels();
            Util_SetJS();
        }
        catch (Exception ex)
        {
            Utilities.ShowError(ex.Message);
        }
    }
예제 #16
0
    protected override void Page_Load(object sender, System.EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!Ektron.Cms.DataIO.LicenseManager.LicenseManager.IsFeatureEnable(m_refContentApi.RequestInformationRef, Ektron.Cms.DataIO.LicenseManager.Feature.eCommerce))
        {
            Utilities.ShowError(m_refContentApi.EkMsgRef.GetMessage("feature locked error"));
        }
        if (!Utilities.ValidateUserLogin())
        {
            return;
        }
        Util_CheckAccess();
        Util_RegisterResources();
        _RegionApi = new RegionApi(); //(Me.m_refContentApi.RequestInformationRef)
        _CountryApi = new CountryApi(); //(Me.m_refContentApi.RequestInformationRef)
        _Criteria.PagingInfo = new PagingInfo(10000);
        _Criteria.AddFilter(CountryProperty.IsEnabled, CriteriaFilterOperator.EqualTo, true);
        AppPath = m_refContentApi.AppPath;

        switch (this.m_sPageAction)
        {
            case "addedit":
                _CountryList = _CountryApi.GetList(_Criteria);
                if (Page.IsPostBack && smUpdateRegion.IsInAsyncPostBack == false)
                {
                    if (Request.Form[isCPostData.UniqueID] == "")
                    {
                        Process_AddEdit();
                    }
                }
                else
                {
                    if (smUpdateRegion.IsInAsyncPostBack == true)
                    {
                        UpdateRegions();
                    }
                    else
                    {
                        Display_AddEdit();
                    }
                }
                break;
            case "del":
                Process_Delete();
                break;
            case "view":
                _CountryList = _CountryApi.GetList(_Criteria);
                Display_View();
                break;
            default:
                _CountryList = _CountryApi.GetList(_Criteria);
                if (Page.IsPostBack == false)
                {
                    Display_All();
                }
                break;
        }
        Util_SetLabels();
        Util_SetJS();
    }
예제 #17
0
    protected void Display_All()
    {
        System.Collections.Generic.List<TaxClassData> TaxClassList = new System.Collections.Generic.List<TaxClassData>();
        Ektron.Cms.Common.Criteria<TaxClassProperty> TaxClasscriteria = new Ektron.Cms.Common.Criteria<TaxClassProperty>(TaxClassProperty.Name, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);
        Ektron.Cms.Common.Criteria<TaxRateProperty> taxCriteria = new Ektron.Cms.Common.Criteria<TaxRateProperty>(TaxRateProperty.TaxClassName, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);
        Ektron.Cms.Common.Criteria<TaxRateProperty> postalCriteria = new Ektron.Cms.Common.Criteria<TaxRateProperty>(TaxRateProperty.PostalCode, EkEnumeration.OrderByDirection.Ascending);
        CountryApi m_refCountryTaxRate = new CountryApi();
        int page_Data = _CurrentPageNumber;
        int i = 0;
        TaxApi taxApi = new TaxApi();
        List<TaxRateData> postalRateList;
        int iCount = 0;
        int k = 0;
        int p = 0;
        int q = 0;
        int r = 0;

        dg_viewall.AutoGenerateColumns = false;
        dg_viewall.Columns.Clear();

        _Criteria.PagingInfo.RecordsPerPage = 10;
        taxCriteria.PagingInfo.RecordsPerPage = 10;
        taxCriteria.Filters.Capacity = 1000;

        ///''

        postalCriteria.AddFilter(TaxRateProperty.TaxTypeId, CriteriaFilterOperator.EqualTo, TaxRateType.PostalSalesTax);

        TaxClassList = _TaxClassApi.GetList(TaxClasscriteria);

        int iCount1 = System.Convert.ToInt32(taxApi.GetList(postalCriteria).Count() / TaxClassList.Count);
        int totalPages = postalCriteria.PagingInfo.TotalPages;

        postalCriteria.PagingInfo.CurrentPage = _CurrentPageNumber;

        postalRateList = taxApi.GetList(postalCriteria);

        iCount = System.Convert.ToInt32(postalRateList.Count / TaxClassList.Count);

        string[] Postal = new string[postalRateList.Count - 1 + 1];
        long[] Region = new long[postalRateList.Count - 1 + 1];

        foreach (PostalCodeTaxRateData PostalRate in postalRateList)
        {
            Postal[k] = PostalRate.PostalCode;
            Region[k] = PostalRate.TypeItemId;
            k++;
        }

        string[] zipcode = new string[iCount + 1];
        long[] regionId = new long[iCount + 1];

        if (Region.Length > 0)
        {
            regionId[p] = Region[r];
        }
        if (Postal.Length > 0)
        {
            zipcode[q] = Postal[p];
        }
        q++;
        r++;

        for (p = 1; p <= postalRateList.Count - 1; p++)
        {
            if (Postal[p] != Postal[p - 1])
            {
                zipcode[q] = Postal[p];
                q++;
            }
        }

        for (p = 1; p <= postalRateList.Count - 1; p++)
        {
            if (Region[p] != Region[p - 1])
            {
                regionId[r] = Region[p];
                r++;
            }
        }
        ///'

        //_TotalPagesNumber = System.Convert.ToInt32(System.Math.Ceiling(Convert.ToDouble(iCount1 / 10)));

        if (totalPages <= 1)
        {
            TotalPages.Visible = false;
            CurrentPage.Visible = false;
            lnkBtnPreviousPage.Visible = false;
            NextPage.Visible = false;
            LastPage.Visible = false;
            FirstPage.Visible = false;
            PageLabel.Visible = false;
            OfLabel.Visible = false;
        }
        else
        {
            lnkBtnPreviousPage.Enabled = true;
            FirstPage.Enabled = true;
            LastPage.Enabled = true;
            NextPage.Enabled = true;
            TotalPages.Visible = true;
            CurrentPage.Visible = true;
            lnkBtnPreviousPage.Visible = true;
            NextPage.Visible = true;
            LastPage.Visible = true;
            FirstPage.Visible = true;
            PageLabel.Visible = true;
            OfLabel.Visible = true;
            //TotalPages.Text = (System.Math.Ceiling(Convert.ToDouble(_TotalPagesNumber))).ToString();

            TotalPages.Text = totalPages.ToString();
            TotalPages.ToolTip = TotalPages.Text;

            CurrentPage.Text = _CurrentPageNumber.ToString();
            CurrentPage.ToolTip = CurrentPage.Text;

            if (_CurrentPageNumber == 1)
            {
                lnkBtnPreviousPage.Enabled = false;
                FirstPage.Enabled = false;
            }
            else if (_CurrentPageNumber == _TotalPagesNumber)
            {
                NextPage.Enabled = false;
                LastPage.Enabled = false;
            }
        }

        System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "Id";
        colBound.HeaderText = m_refMsg.GetMessage("generic id");
        colBound.ItemStyle.Wrap = false;
        colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
        colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
        dg_viewall.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "Postal Code";
        colBound.HeaderText = m_refMsg.GetMessage("lbl address postal"); // + "(" + m_refMsg.GetMessage("lbl view tax rate for region") + ")";
        colBound.ItemStyle.Wrap = false;
        colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
        colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
        dg_viewall.Columns.Add(colBound);

        dg_viewall.BorderColor = System.Drawing.Color.White;

        DataTable dt = new DataTable();
        DataRow dr;

        dt.Columns.Add(new DataColumn("Id", typeof(string)));
        dt.Columns.Add(new DataColumn("Postal Code", typeof(string)));

        if (!(postalRateList == null))
        {

            for (i = 0; i <= (zipcode.Length - 1); i++)
            {
                if (!string.IsNullOrEmpty(zipcode[i]))
                {
                    dr = dt.NewRow();
                    dr[0] = "<a href=\"postaltaxtables.aspx?action=View&postalid=" + zipcode[i].ToString() + "&id=" + regionId[i] + "\">" + regionId[i] + "</a>";
                    dr[1] = "<a onmouseover=\"expandcontent(\'sc" + i + "\')\" onmouseout=\"expandcontent(\'sc" + i + "\')\" href=\"postaltaxtables.aspx?action=View&postalid=" + zipcode[i].ToString() + "&id=" + regionId[i] + "\">" + zipcode[i] + "</a>";
                    dr[1] += "<div class=\"switchcontent\" style=\"position:absolute;\" id=\"sc" + i + "\">";
                    dr[1] += "<table>";
                    foreach (TaxClassData taxClass in TaxClassList)
                    {
                        dr[1] += "<tr><td width=\"50%\"><label id=\"" + taxClass.Name + "\">" + taxClass.Name + "</label></td>";
                        dr[1] += "<td width=\"20px\"><label id=\"value\">" + GetRate(taxClass.Id, regionId[i]) * 100 + "</label>" + "<label id=\"lblPercentage\">" + "&nbsp;%" + "</label></td></tr>";
                    }
                    dr[1] += "</table></div>";
                    dt.Rows.Add(dr);
                }
            }
        }
        DataView dv = new DataView(dt);

        dg_viewall.DataSource = dv;
        dg_viewall.DataBind();
    }
예제 #18
0
    protected override void Page_Load(object sender, System.EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!Ektron.Cms.DataIO.LicenseManager.LicenseManager.IsFeatureEnable(m_refContentApi.RequestInformationRef, Ektron.Cms.DataIO.LicenseManager.Feature.eCommerce))
        {
            Utilities.ShowError(m_refContentApi.EkMsgRef.GetMessage("feature locked error"));
        }
        if (!Utilities.ValidateUserLogin())
        {
            return;
        }
        Util_CheckAccess();
        Util_RegisterResources();
        if (Page.Request.QueryString["search"] != "")
        {
            _SearchCriteria = Page.Request.QueryString["search"];
        }
        _RegionApi = new RegionApi(); //(Me.m_refContentApi.RequestInformationRef)
        _CountryApi = new CountryApi(); //(Me.m_refContentApi.RequestInformationRef)
        _CountryCriteria.PagingInfo = new PagingInfo(10000);

        hdnCurrentPage.Value = CurrentPage.Text;
        switch (this.m_sPageAction)
        {
            case "addedit":
                _CountryList = _CountryApi.GetList(_CountryCriteria);
                if (Page.IsPostBack)
                {
                    Process_AddEdit();
                }
                else
                {
                    Display_AddEdit();
                }
                break;
            case "del":
                Process_Delete();
                break;
            case "view":
                _CountryList = _CountryApi.GetList(_CountryCriteria);
                Display_View();
                break;
            default:
                _CountryCriteria.Condition = LogicalOperation.Or;
                if (_SearchCriteria != "")
                {
                    _CountryCriteria.AddFilter(CountryProperty.Name, Ektron.Cms.Common.CriteriaFilterOperator.Contains, _SearchCriteria);
                }
                if (_SearchCriteria != "")
                {
                    _CountryCriteria.AddFilter(CountryProperty.LongIsoCode, Ektron.Cms.Common.CriteriaFilterOperator.Contains, _SearchCriteria);
                }
                if (_SearchCriteria != "")
                {
                    _CountryCriteria.AddFilter(CountryProperty.ShortIsoCode, Ektron.Cms.Common.CriteriaFilterOperator.Contains, _SearchCriteria);
                }
                _CountryList = _CountryApi.GetList(_CountryCriteria);
                if (Page.IsPostBack == false)
                {
                    Display_All();
                }
                break;
        }
        Util_SetLabels();
        Util_SetJS();
    }
예제 #19
0
    protected void Display_All()
    {
        System.Collections.Generic.List<TaxRateData> RateList = new System.Collections.Generic.List<TaxRateData>();
        System.Collections.Generic.List<TaxClassData> TaxClassList = new System.Collections.Generic.List<TaxClassData>();
        Ektron.Cms.Common.Criteria<TaxClassProperty> TaxClasscriteria = new Ektron.Cms.Common.Criteria<TaxClassProperty>(TaxClassProperty.Name, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);
        Ektron.Cms.Common.Criteria<CountryProperty> countryCriteria = new Ektron.Cms.Common.Criteria<CountryProperty>(CountryProperty.Name, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);
        int i = 0;
        dg_viewall.PageSize = m_refContentApi.RequestInformationRef.PagingSize;
        countryCriteria.PagingInfo.RecordsPerPage = m_refContentApi.RequestInformationRef.PagingSize;
        countryCriteria.PagingInfo.CurrentPage = _CurrentPageNumber;

        _TaxApi = new TaxApi();
        TaxClassList = _TaxClassApi.GetList(TaxClasscriteria);

        dg_viewall.AutoGenerateColumns = false;
        dg_viewall.Columns.Clear();

        System.Collections.Generic.List<CountryData> CountryRateList = new System.Collections.Generic.List<CountryData>();
        CountryApi m_refCountryTaxRate = new CountryApi();
        m_refCountryTaxRate = new CountryApi();

        countryCriteria.Condition = LogicalOperation.Or;
        if (_SearchCriteria != "")
        {
            countryCriteria.AddFilter(CountryProperty.Name, Ektron.Cms.Common.CriteriaFilterOperator.Contains, _SearchCriteria);
        }
        if (_SearchCriteria != "")
        {
            countryCriteria.AddFilter(CountryProperty.LongIsoCode, Ektron.Cms.Common.CriteriaFilterOperator.Contains, _SearchCriteria);
        }
        if (_SearchCriteria != "")
        {
            countryCriteria.AddFilter(CountryProperty.ShortIsoCode, Ektron.Cms.Common.CriteriaFilterOperator.Contains, _SearchCriteria);
        }

        CountryRateList = m_refCountryTaxRate.GetList(countryCriteria);

        _TotalPagesNumber = System.Convert.ToInt32(countryCriteria.PagingInfo.TotalPages);
        TotalPages.ToolTip = _TotalPagesNumber.ToString();

        if (_TotalPagesNumber <= 1)
        {
            TotalPages.Visible = false;
            CurrentPage.Visible = false;
            lnkBtnPreviousPage.Visible = false;
            NextPage.Visible = false;
            LastPage.Visible = false;
            FirstPage.Visible = false;
            PageLabel.Visible = false;
            OfLabel.Visible = false;
        }
        else
        {
            lnkBtnPreviousPage.Enabled = true;
            FirstPage.Enabled = true;
            LastPage.Enabled = true;
            NextPage.Enabled = true;
            TotalPages.Visible = true;
            CurrentPage.Visible = true;
            lnkBtnPreviousPage.Visible = true;
            NextPage.Visible = true;
            LastPage.Visible = true;
            FirstPage.Visible = true;
            PageLabel.Visible = true;
            OfLabel.Visible = true;
            TotalPages.Text = (System.Math.Ceiling(Convert.ToDouble(_TotalPagesNumber))).ToString();
            TotalPages.ToolTip = TotalPages.Text;

            CurrentPage.Text = _CurrentPageNumber.ToString();
            CurrentPage.ToolTip = CurrentPage.Text;

            if (_CurrentPageNumber == 1)
            {
                lnkBtnPreviousPage.Enabled = false;
                FirstPage.Enabled = false;
            }
            else if (_CurrentPageNumber == _TotalPagesNumber)
            {
                NextPage.Enabled = false;
                LastPage.Enabled = false;
            }
        }

        System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "Id";
        colBound.HeaderText = this.GetMessage("generic id");
        colBound.ItemStyle.Wrap = false;
        colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
        colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
        dg_viewall.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "Name";
        colBound.HeaderText = this.GetMessage("generic name")+" (" + m_refMsg.GetMessage("lbl view tax rate for region") + ")";
        colBound.ItemStyle.Wrap = false;
        colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
        colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
        dg_viewall.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "Enabled";
        colBound.HeaderText = this.GetMessage("enabled");
        colBound.ItemStyle.Wrap = false;
        colBound.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
        colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
        dg_viewall.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "Code";
        colBound.HeaderText = this.GetMessage("lbl code");
        colBound.ItemStyle.Wrap = false;
        colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
        colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
        dg_viewall.Columns.Add(colBound);

        dg_viewall.BorderColor = System.Drawing.Color.White;

        DataTable dt = new DataTable();
        DataRow dr;

        dt.Columns.Add(new DataColumn("Id", typeof(string)));
        dt.Columns.Add(new DataColumn("Name", typeof(string)));
        dt.Columns.Add(new DataColumn("Enabled", typeof(string)));
        dt.Columns.Add(new DataColumn("Code", typeof(string)));
        dt.Columns.Add(new DataColumn("Country", typeof(string)));

        if (!(CountryRateList == null))
        {

            for (i = 0; i <= (CountryRateList.Count - 1); i++)
            {
                dr = dt.NewRow();
                dr[0] = "<a  href=\"countrytaxtables.aspx?action=View&id=" + CountryRateList[i].Id + "\">" + CountryRateList[i].Id + "</a>";
                dr[1] = "<a href=\"#ExpandContent\" onclick=\"expandcontent(\'sc" + i + "\');return false;\">" + CountryRateList[i].Name + "</a><br />";

                dr[1] += "<div class=\"switchcontent\" id=\"sc" + i + "\"><table class=\"ektronForm\"><a onclick=\"expandcontent(\'sc" + i + "\')\" href=\"countrytaxtables.aspx?action=View&id=" + CountryRateList[i].Id + "\">" + m_refMsg.GetMessage("lbl view tax rate") + "</a><br />";
                foreach (TaxClassData taxClass in TaxClassList)
                {
                    dr[1] += "<tr><td><br/><label class=\"label\" id=\"" + taxClass.Name + "\">" + taxClass.Name + "</label></td>";
                    dr[1] += "<td><input type=\"text\" size=\"10\" align=\"right\" name=\"value\" readonly=\"true\" id=\"value\" value=\"" + GetRate(taxClass.Id, CountryRateList[i].Id) * 100 + "\"/>" + "<label id=\"lblPercentage\">" + "%" + "</label></td></tr>";
                }

                dr[1] += "</table></div>";

                dr[2] = "<input type=\"CheckBox\" ID=\"chk_enabled" + i + "\" disabled=\"true\"  " + ((CountryRateList[i].Enabled) ? "Checked=\"checked\"" : "") + "/>";
                dr[3] = "<a href=\"countrytaxtables.aspx?action=View&id=" + CountryRateList[i].Id + "\">" + CountryRateList[i].ShortIsoCode + "</a>";
                dt.Rows.Add(dr);
            }
        }
        DataView dv = new DataView(dt);

        dg_viewall.DataSource = dv;
        dg_viewall.DataBind();
    }
예제 #20
0
    protected override void Page_Load(object sender, System.EventArgs e)
    {
        base.Page_Load(sender, e);

        if (!Ektron.Cms.DataIO.LicenseManager.LicenseManager.IsFeatureEnable(m_refContentApi.RequestInformationRef, Ektron.Cms.DataIO.LicenseManager.Feature.eCommerce))
        {
            Utilities.ShowError(m_refContentApi.EkMsgRef.GetMessage("feature locked error"));
        }
        RegisterResources();
        AppPath = m_refContentApi.ApplicationPath;

        try
        {

            if (!Utilities.ValidateUserLogin())
            {
                return;
            }
            CommerceLibrary.CheckCommerceAdminAccess();

            System.Web.HttpCookie siteCookie = CommonApiBase.GetEcmCookie();
            Ektron.Cms.Commerce.CurrencyApi m_refCurrencyApi = new Ektron.Cms.Commerce.CurrencyApi();
            defaultCurrency = (new CurrencyApi()).GetItem(m_refContentApi.RequestInformationRef.CommerceSettings.DefaultCurrencyId);

            if (siteCookie["SiteCurrency"] != defaultCurrency.Id.ToString())
            {
                defaultCurrency.Id = Convert.ToInt32(siteCookie["SiteCurrency"]);
                defaultCurrency = m_refCurrencyApi.GetItem(defaultCurrency.Id);
            }

            if (!string.IsNullOrEmpty(Request.QueryString["customerid"]))
            {
                m_iCustomerId = Convert.ToInt64(Request.QueryString["customerid"]);
            }
            defaultCurrency = (new CurrencyApi()).GetItem(m_refContentApi.RequestInformationRef.CommerceSettings.DefaultCurrencyId);
            CustomerManager = new CustomerApi();
            AddressManager = new AddressApi();

            if (siteCookie["SiteCurrency"] != defaultCurrency.Id.ToString())
            {
                defaultCurrency.Id = Convert.ToInt32(siteCookie["SiteCurrency"]);
                defaultCurrency = m_refCurrencyApi.GetItem(defaultCurrency.Id);
            }

            switch (base.m_sPageAction)
            {
                case "addeditaddress":
                    RegionManager = new RegionApi();
                    CountryManager = new CountryApi();
                    if (Page.IsPostBack)
                    {
                        if (Request.Form[isCPostData.UniqueID] == "")
                        {
                            Process_ViewAddress();
                        }
                    }
                    else
                    {
                        Display_ViewAddress(true);
                    }
                    break;
                case "viewaddress":
                    RegionManager = new RegionApi();
                    CountryManager = new CountryApi();
                    Display_ViewAddress(false);
                    break;
                case "viewbasket":
                    Display_ViewBaskets(false);
                    break;
                case "view":
                    Display_View();
                    break;
                case "deleteaddress":
                    Process_AddressDelete();
                    break;
                case "deletebasket":
                    Process_BasketDelete();
                    break;
                default: // "viewall"
                    if (Page.IsPostBack == false)
                    {
                        Display_View_All();
                    }
                    break;
            }
            Util_SetLabels();
            Util_SetJS();
        }
        catch (Exception ex)
        {
            Utilities.ShowError(ex.Message);
        }
    }
예제 #21
0
    protected override void Page_Load(object sender, System.EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!Ektron.Cms.DataIO.LicenseManager.LicenseManager.IsFeatureEnable(m_refContentApi.RequestInformationRef, Ektron.Cms.DataIO.LicenseManager.Feature.eCommerce))
        {
            Utilities.ShowError(m_refContentApi.EkMsgRef.GetMessage("feature locked error"));
        }
        if (!Utilities.ValidateUserLogin())
        {
            return;
        }
        this.CommerceLibrary.CheckCommerceAdminAccess();
        Util_RegisterResources();
        m_refRegion = new RegionApi();
        m_refCountry = new CountryApi();
        criteria.PagingInfo = new PagingInfo(10000);
        RegionCriteria.PagingInfo = new PagingInfo(10000);
        CountryList = m_refCountry.GetList(criteria);
        RegionList = m_refRegion.GetList(RegionCriteria);

        try
        {
            switch (base.m_sPageAction)
            {
                case "markdef":
                    Process_MarkDefault();
                    break;
                case "del":
                    Process_Delete();
                    break;
                case "addedit":
                    if (Page.IsPostBack && smAddressCountry.IsInAsyncPostBack == false)
                    {
                        Process_AddEdit();
                    }
                    else if (smAddressCountry.IsInAsyncPostBack == true)
                    {
                        Util_BindRegions((string)drp_address_country.SelectedValue);
                    }
                    else
                    {
                        Display_AddEdit();
                    }
                    break;
                case "view":
                    Display_View();
                    break;
                default: // "viewall"
                    if (Page.IsPostBack == false)
                    {
                        Display_View_All();
                    }
                    break;
            }
            SetLabels();
        }
        catch (Exception ex)
        {
            Utilities.ShowError(ex.Message);
        }
    }