public static ShippingAssignment ToShippingAssignment(this CustomerOrder order)
        {
            ICountryAdapter countryAdapter = new CountryAdapter();
            var             shipping       = new ShippingAssignment()
            {
                Order = order
            };

            shipping.Shipper = countryAdapter.GetShippingPartner(order);

            return(shipping);
        }
        public void OrderOther_Success()
        {
            // ARRANGE
            ICountryAdapter adapter = new CountryAdapter();
            var             order   = new CustomerOrder()
            {
                CustomerId = 1,
                Weight     = 11,
                Country    = "France"
            };
            // ACT
            var assignment = adapter.GetShippingPartner(order);

            // ASSESS
            Assert.Equal("DHL", assignment);
        }
        public void OrderNetherlands_9kg_Success()
        {
            // ARRANGE
            ICountryAdapter adapter = new CountryAdapter();
            var             order   = new CustomerOrder()
            {
                CustomerId = 1,
                Weight     = 9,
                Country    = "Netherlands"
            };
            // ACT
            var assignment = adapter.GetShippingPartner(order);

            // ASSESS
            Assert.Equal("PostNL", assignment);
        }
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            try
            {
                SetContentView(Resource.Layout.YourSpecialization);
                recyclerView       = FindViewById <RecyclerView>(Resource.Id.recyclerView);
                headerTV           = FindViewById <TextView>(Resource.Id.headerTV);
                back_button        = FindViewById <ImageButton>(Resource.Id.back_button);
                backRelativeLayout = FindViewById <RelativeLayout>(Resource.Id.backRelativeLayout);
                headerTV.Text      = GetString(Resource.String.country);
                searchBn           = FindViewById <Button>(Resource.Id.searchBn);
                activityIndicator  = FindViewById <ProgressBar>(Resource.Id.activityIndicator);
                activityIndicator.IndeterminateDrawable.SetColorFilter(Resources.GetColor(Resource.Color.buttonBackgroundColor), Android.Graphics.PorterDuff.Mode.Multiply);
                searchBn.Visibility = ViewStates.Gone;
                Typeface tf = Typeface.CreateFromAsset(Assets, "Roboto-Regular.ttf");

                headerTV.SetTypeface(tf, TypefaceStyle.Bold);
                FindViewById <EditText>(Resource.Id.searchET).SetTypeface(tf, TypefaceStyle.Normal);
                searchBn.SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.nothingTV).SetTypeface(tf, TypefaceStyle.Normal);


                backRelativeLayout.Click += (s, e) =>
                {
                    OnBackPressed();
                };
                back_button.Click += (s, e) =>
                {
                    OnBackPressed();
                };
                activityIndicator.Visibility = ViewStates.Visible;
                var countriesJson = await countryMethods.GetCountries();

                activityIndicator.Visibility = ViewStates.Gone;
                layoutManager = new LinearLayoutManager(this, LinearLayoutManager.Vertical, false);
                recyclerView.SetLayoutManager(layoutManager);
                var deserialized_countries = JsonConvert.DeserializeObject <List <City> >(countriesJson);
                var countryAdapter         = new CountryAdapter(deserialized_countries, this, tf);
                recyclerView.SetAdapter(countryAdapter);
            }
            catch
            {
                StartActivity(typeof(MainActivity));
            }
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);
            Cheeseknife.Inject(this);

            countries = GetJsonFromAsset <Country>("countries.json");
            adapter   = new CountryAdapter(countries);
            rvCountries.SetLayoutManager(new LinearLayoutManager(this));
            rvCountries.SetAdapter(adapter);

            searchView = FindViewById <Android.Widget.SearchView>(Resource.Id.searchView);
            searchView.QueryTextChange += (sender, e) =>
            {
                adapter = new CountryAdapter(countries.FindAll(country => country.Name.ToLower().Contains(searchView.Query)));
                rvCountries.SetAdapter(adapter);
            };
        }
        private void Init()
        {
            var stream = Application.Context.Assets.Open("Countries.json");

            using (var streamReader = new StreamReader(stream))
            {
                var content = streamReader.ReadToEnd();
                countries = JsonConvert.DeserializeObject <List <Country> >(content);
            }
            recyclerView.SetLayoutManager(new LinearLayoutManager(this));
            adapter = new CountryAdapter(countries);
            recyclerView.SetAdapter(adapter);

            searchView.QueryTextChange += (s, e) => adapter.Filter.InvokeFilter(e.NewText);
            searchView.QueryTextSubmit += (s, e) =>
            {
                Toast.MakeText(this, "Search for: " + e.Query, ToastLength.Short).Show();
                e.Handled = true;
            };
        }
Ejemplo n.º 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);

            var recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView1);

            var layoutManager = new LinearLayoutManager(this);

            recyclerView.SetLayoutManager(layoutManager);

            var input = Assets.Open("Countries.json");

            using (var streamReader = new StreamReader(input))
            {
                var content = streamReader.ReadToEnd();
                countries = JsonConvert.DeserializeObject <List <Country> >(content)
                            .GroupBy(x => x.Name.First())
                            .Select(x => new List <object>()
                {
                    x.Key.ToString()
                }.Union(x))
                            .SelectMany(x => x)
                            .ToList();

                adapter = new CountryAdapter(countries);
            }

            recyclerView.SetAdapter(adapter);
            adapter.NotifyDataSetChanged();

            var searchView = FindViewById <SearchView>(Resource.Id.sv_country);

            searchView.QueryTextChange += delegate
            {
                adapter.Countries = countries.Where(x => x is Country ? ((Country)x).Name.Contains(searchView.Query) : x.ToString().Contains(searchView.Query))
                                    .ToList <object>();;
                recyclerView.SetAdapter(adapter);
            };
        }
Ejemplo n.º 8
0
        internal List <CountryEntity> GetCountries()
        {
            List <CountryEntity> results = new List <CountryEntity>();

            try
            {
                StoredProcedureEntity sproc = new StoredProcedureEntity();
                sproc.StoredProcedureName = "dnb.GetCountryList";

                DataTable dt;
                dt = sql.ExecuteDataTable(CommandType.StoredProcedure, sproc);
                if (dt != null && dt.Rows.Count > 0)
                {
                    results = new CountryAdapter().Adapt(dt);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(results);
        }
Ejemplo n.º 9
0
            protected override void OnPostExecute(string result)
            {
                //var dataobj = new CountryStatus();
                //List<string> datelist = new List<string>();
                //List<string> caseslist = new List<string>();
                try
                {
                    base.OnPostExecute(result);

                    if (result.Contains("Error:"))
                    {
                        return;
                    }
                    var    parsed = JsonConvert.DeserializeObject <List <CountryStatus> >(result);
                    string cas    = parsed[0].Country;
                    for (int i = 0; i < parsed.Count - 1; i++)
                    {
                        CountryList obj = new CountryList();
                        obj.country = parsed[i].Country;
                        string [] strarr = parsed[i].Date.ToString().Split(" ", 2);
                        obj.date   = strarr[0];
                        obj.cases  = parsed[i].Cases.ToString();
                        obj.status = parsed[i].Status.ToString();
                        conlist.Add(obj);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("Exception : " + ex.Message);
                    return;
                }
                CountryAdapter adapter = new CountryAdapter(activity, conlist);

                activity.mainList.Adapter    = adapter;
                activity.mainList.ItemClick += listView_ItemClick;
            }
Ejemplo n.º 10
0
        void InitWithAdapter()
        {
            List <Country> countries = new Util.CountryUtil(Context).AvailableCountries;

            Adapter = new CountryAdapter(Context, countries);
        }