Exemple #1
0
        public static NearbyInformation GetNearby(Countries country, string zipcode)
        {
            var result = new NearbyInformation();
            var returnedJson = Core.GetNearbyStraigth(country, zipcode);
            var o = JObject.Parse(returnedJson);

            result = JsonConvert.DeserializeObject<NearbyInformation>(returnedJson);

            result.NearLongitude = double.Parse((string)o["near longitude"], CultureInfo.InvariantCulture);
            result.NearLatitude = double.Parse((string)o["near latitude"], CultureInfo.InvariantCulture);

            var nearbies = (JArray)o["nearby"];

            for (var i = 0; i < nearbies.Count; i++)
            {
                var nearby       = new Nearby();
                nearby.Distance  = double.Parse((string)nearbies[i]["distance"], CultureInfo.InvariantCulture);
                nearby.PlaceName = (string)nearbies[i]["place name"];
                nearby.State     = (string)nearbies[i]["state"];
                nearby.StateCode = (string)nearbies[i]["state abbreviation"];
                nearby.ZipCode   = (string)nearbies[i]["postal code"];

                result.Nearbies.Add(nearby);
            }

            return result;
        }
Exemple #2
0
 /// <summary>
 /// Code only at one place
 /// </summary>
 /// <param name="street"></param>
 /// <param name="zip"></param>
 /// <param name="city"></param>
 /// <param name="country"></param>
 public Address(string street, string city, string zip, Countries country)
 {
     this.street = street;
     this.zip = zip;
     this.city = city;
     this.country = country;
 }
Exemple #3
0
 // defining consturctors
 /// <summary>
 /// Constructor with 4 parameters.  This is  constructor that has most
 /// number of parameters. It is in this constructor that all coding 
 /// should be done.
 /// </summary>
 /// <param name="street">Input - street name</param>
 /// <param name="zip">Input - zip code</param>
 /// <param name="city">Input - city name</param>
 /// <param name="country">Input - country name</param>
 public Address(string street, string zip, string city, Countries country)
 {
     m_city = city;
        m_street = street;
        m_zipCode = zip;
        m_country = country;
 }
        public CountriesResponse Post(Countries request)
        {
            if (request.Country.Id > 0)
              {
            Bm2s.Data.Common.BLL.Parameter.Country item = Datas.Instance.DataStorage.Countries[request.Country.Id];
            item.Code = request.Country.Code;
            item.EndingDate = request.Country.EndingDate;
            item.Name = request.Country.Name;
            item.StartingDate = request.Country.StartingDate;
            Datas.Instance.DataStorage.Countries[request.Country.Id] = item;
              }
              else
              {
            Bm2s.Data.Common.BLL.Parameter.Country item = new Data.Common.BLL.Parameter.Country()
            {
              Code = request.Country.Code,
              EndingDate = request.Country.EndingDate,
              Name = request.Country.Name,
              StartingDate = request.Country.StartingDate
            };

            Datas.Instance.DataStorage.Countries.Add(item);
            request.Country.Id = item.Id;
              }

              CountriesResponse response = new CountriesResponse();
              response.Countries.Add(request.Country);
              return response;
        }
        public decimal Calculate(decimal price, Countries country)
        {
            decimal taxPrice = default(decimal);
            // Call Real Web Service to determine the VAT Tax.
            switch (country)
            {
                case Countries.Bulgaria:
                    taxPrice = CalculateTaxPriceInternal(price, 20);
                    break;
                case Countries.Germany:
                    taxPrice = CalculateTaxPriceInternal(price, 19);
                    break;
                case Countries.Austria:
                    taxPrice = CalculateTaxPriceInternal(price, 20);
                    break;
                case Countries.France:
                    taxPrice = CalculateTaxPriceInternal(price, 23);
                    break;
                default:
                    taxPrice = 0;
                    break;
            }

            return taxPrice;
        }
Exemple #6
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="theOther"></param>
 public Address(Address origAddress)
 {
     this.street = origAddress.street;
     this.zip = origAddress.zip;
     this.city = origAddress.city;
     this.country = origAddress.country;
 }
 private void Initialize()
 {
     countries = new Countries(session);
     cities = new Cities(session);
     venues = new Venues(session);
     users = new Users(session);
     sports = new Sports(session);
     goals = new Goals(session);
 }
Exemple #8
0
        private void InitializeDATA()
        {
            Countries = new Countries();
            tmpCountries = Countries;
            DataContext = tmpCountries;

            FilterIntelliSense txtBoxFilter = new FilterIntelliSense("LearnDATAGRID.Country");
            gridFilter.Children.Add(txtBoxFilter);
        }
        // http://localhost/endurancegoals/cities/of/spain
        public ActionResult of([Bind(Prefix = "id")] string countryName)
        {
            Countries goals = new Countries(SessionProvider.OpenSession());

            var cityList = goals.GetByName(countryName).Cities;

            var jsonGoals = GetCityList(cityList);

            return Json(jsonGoals, JsonRequestBehavior.AllowGet);
        }
        public CountriesResponse Delete(Countries request)
        {
            Bm2s.Data.Common.BLL.Parameter.Country item = Datas.Instance.DataStorage.Countries[request.Country.Id];
              item.EndingDate = DateTime.Now;
              Datas.Instance.DataStorage.Countries[item.Id] = item;

              CountriesResponse response = new CountriesResponse();
              response.Countries.Add(request.Country);
              return response;
        }
        public CountriesResponse Get(Countries request)
        {
            CountriesResponse response = new CountriesResponse();
              List<Bm2s.Data.Common.BLL.Parameter.Country> items = new List<Data.Common.BLL.Parameter.Country>();
              if (!request.Ids.Any())
              {
            items.AddRange(Datas.Instance.DataStorage.Countries.Where(item =>
              (string.IsNullOrWhiteSpace(request.Code) || item.Code.ToLower().Contains(request.Code.ToLower())) &&
              (string.IsNullOrWhiteSpace(request.Name) || item.Name.ToLower().Contains(request.Name.ToLower())) &&
              (!request.Date.HasValue || (request.Date >= item.StartingDate && (!item.EndingDate.HasValue || request.Date < item.EndingDate.Value)))
              ));
              }
              else
              {
            items.AddRange(Datas.Instance.DataStorage.Countries.Where(item => request.Ids.Contains(item.Id)));
              }

              var collection = (from item in items
                        select new Bm2s.Poco.Common.Parameter.Country()
                        {
                          Code = item.Code,
                          EndingDate = item.EndingDate,
                          Id = item.Id,
                          Name = item.Name,
                          StartingDate = item.StartingDate
                        }).AsQueryable().OrderBy(request.Order, !request.DescendingOrder);

              response.ItemsCount = collection.Count();
              if (request.PageSize > 0)
              {
            response.Countries.AddRange(collection.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize));
              }
              else
              {
            response.Countries.AddRange(collection);
              }

              try
              {
            response.PagesCount = collection.Count() / response.Countries.Count + (collection.Count() % response.Countries.Count > 0 ? 1 : 0);
              }
              catch
              {
            response.PagesCount = 1;
              }

              return response;
        }
 public void SetCountryFromCity(Cities city) {
     switch (city) {
         case Cities.LONDON:
             Country = Countries.UK;
             break;
         case Cities.PARIS:
             Country = Countries.FRANCE;
             break;
         case Cities.CHICAGO:
             Country = Countries.USA;
             break;
         default:
             Country = Countries.NONE;
             break;
     }
 }
        private void Initialize()
        {
            InitalizeSessionFactory(
                typeof (Country).Assembly,
                typeof (Goal).Assembly,
                typeof (User).Assembly,
                typeof (Venue).Assembly,
                typeof (Country).Assembly,
                typeof (Sport).Assembly);

            countries = new Countries(session);
            cities = new Cities(session);
            venues = new Venues(session);
            users = new Users(session);
            sports = new Sports(session);
            goals = new Goals(session);
            goalParticipants = new GoalParticipants(session);
        }
 protected void IMGBTNCSCisActive_Click(object sender, ImageClickEventArgs e)
 {
     ImageButton lnk = (ImageButton)sender;
     int userid = Convert.ToInt32(lnk.CommandArgument);
     objprodctg = null;
     objprodctg = ObjprodClass.GetCountriesByID(userid);
     if (objprodctg != null)
     {
         if (objprodctg.IsActive == true)
             ChkIsActiveCSC.Checked = true;
         TXTCSC.Text = objprodctg.Name.ToString();
         errorpopheaderCSC.Style.Add("display", "none");
         DIVIsActive.Style.Add("display", "block");
         btnSubmitCSC.Text = "Update";
         ViewState["popupID"] = userid.ToString();
         ScriptManager.RegisterStartupScript(this, typeof(Page), "aa", "jQuery(document).ready(function(){ShowPOPUPCSCUpdate('true');});", true);
     }
 }
 public void SetCountryFromCity(Cities city)
 {
     switch (city)
     {
         case Cities.London:
             Country = Countries.UK;
             break;
         case Cities.Paris:
             Country = Countries.FRANCE;
             break;
         case Cities.Chicago:
             Country = Countries.USA;
             break;
         default:
             Country = Countries.None;
             break;
     }
 }
Exemple #16
0
        /// <summary>
        ///   Ritorna la lista dei server di un determinato paese
        /// </summary>
        /// <param name = "country">Il paese di cui si vuole ottenere la lista</param>
        /// <exception cref = "NotConnectedException">Solleva un eccezione se non si è connessi a internet</exception>
        /// <returns>Coppia "Descrizione" -> "url"</returns>
        public static Dictionary<String, String> GetServerList(Countries country)
        {
            var dict = new Dictionary<String, String>();
            var wb = new WebBrowser();
            wb.Navigate(country.GetDescription());

            while (wb.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }

            if (wb.Document == null) throw new NotConnectedException();

            foreach (HtmlElement element in wb.Document.GetElementById("serverLogin").Children)
            {
                dict.Add(element.InnerText, element.GetAttribute("value"));
            }

            return dict;
        }
Exemple #17
0
        public async Task <ActionResult <Countries> > PostCountries(Countries countries)
        {
            _context.Countries.Add(countries);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (CountriesExists(countries.country_id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetCountries", new { id = countries.country_id }, countries));
        }
        public async Task <Countries> GetCountryByIdAsync(Guid id)
        {
            Countries ctry = new Countries();

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                string     sql = "SELECT * FROM Countries Where ID = @Id";
                SqlCommand cmd = new SqlCommand(sql, con)
                {
                    CommandType = System.Data.CommandType.Text,
                };
                cmd.Parameters.AddWithValue("@Id", id);

                con.Open();
                SqlDataReader reader = await cmd.ExecuteReaderAsync();

                ctry = (await GetData(reader))[0];
                con.Close();
            }
            return(ctry);
        }
        public async Task <Countries> GetCountryByName(string country)
        {
            Countries Ctry = new Countries();

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                string     sql = "Select * From Countries Where Country = @Origin";
                SqlCommand cmd = new SqlCommand(sql, con)
                {
                    CommandType = System.Data.CommandType.Text,
                };
                cmd.Parameters.AddWithValue("@Origin", country);

                con.Open();
                SqlDataReader reader = await cmd.ExecuteReaderAsync();

                Ctry = (await GetData(reader))[0];
                con.Close();
            }
            return(Ctry);
        }
Exemple #20
0
        }                                               //国家

        /// <summary>
        /// 根据城市设置国家
        /// </summary>
        /// <param name="city">用户城市名</param>
        public void SetCountryFromCity(Cities city)
        {
            switch (city)
            {
            case Cities.LONDON:
                Country = Countries.UK;
                break;

            case Cities.PARIS:
                Country = Countries.FRANCE;
                break;

            case Cities.CHICAGO:
                Country = Countries.USA;
                break;

            default:
                Country = Countries.NONE;
                break;
            }
        }
        private void executemethod(object parameter)
        {
            var    values = (object[])parameter;
            string name   = (string)values[0];
            bool   check  = (bool)values[1];

            if (check)
            {
                Countries.Add(name);
            }
            else
            {
                Countries.Remove(name);
            }

            Name = "";
            foreach (string item in Countries)
            {
                Name = Name + item;
            }
        }
Exemple #22
0
        public void SetCountryFromCity(Cities city)
        {
            switch (city)
            {
            case Cities.London:
                Country = Countries.Uk;
                break;

            case Cities.Paris:
                Country = Countries.France;
                break;

            case Cities.Chicago:
                Country = Countries.Usa;
                break;

            default:
                Country = Countries.None;
                break;
            }
        }
Exemple #23
0
        public async Task <IActionResult> SignUp(string Id)
        {
            var countryList = Countries.CountryList();
            var model       = new SignUpModel
            {
                Country = countryList.OrderBy(a => a).ToList(),
                Errors  = false
            };

            var manager   = _context.ManagerFactory.CreateSignupLinkManager();
            var linkModel = await manager.GetLink(Id);

            if (linkModel != null)
            {
                return(View(model));
            }
            else
            {
                return(Unauthorized());
            }
        }
Exemple #24
0
        private static Countries GetById(int index)
        {
            Countries result = Countries.ARGENTINA;
            int       i      = 0;

            foreach (Countries child in Enum.GetValues(typeof(Countries)))
            {
                if (i == index)
                {
                    result = child;
                    break;
                }
                else
                {
                    i++;
                }
            }


            return(result);
        }
        public void SetCountryFromCity(Cities city)
        {
            switch (city)
            {
            case Cities.LONDON:
                Country = Countries.ENG;
                break;

            case Cities.PARIS:
                Country = Countries.FRA;
                break;

            case Cities.MOSCOW:
                Country = Countries.RUS;
                break;

            default:
                Country = Countries.NONE;
                break;
            }
        }
        public ActionResult addCountry(Countries model)
        {
            if (ModelState.IsValid)
            {
                using (NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities())
                {
                    Countries cr = new Countries();
                    cr.CountryCode = model.CountryCode;
                    cr.CountryName = model.CountryName;
                    cr.IsActive    = true;
                    cr.CreatedDate = DateTime.Now;

                    DBobj.Countries.Add(cr);
                    DBobj.SaveChanges();

                    ModelState.Clear();
                    ViewBag.countrySuccess = "<p><span><i class='fas fa-check-circle'></i></span> Country added successfully.</p>";
                }
            }
            return(View());
        }
        public async Task Search(Dictionary <string, string> dic)
        {
            if (string.IsNullOrEmpty(SearchKey))
            {
                return;
            }

            switch (SelectedSite.Cred.Site)
            {
            case SiteType.YouTube:

                if (SelectedCountry.Key == dlindex)
                {
                    SelectedCountry = Countries.First();
                }

                SelectedCountry.Value.Clear();

                List <VideoItemPOCO> lst = await YouTubeSite.SearchItemsAsync(SearchKey, SelectedCountry.Key, 50).ConfigureAwait(true);

                if (lst.Any())
                {
                    foreach (IVideoItem item in lst.Select(poco => VideoItemFactory.CreateVideoItem(poco, SiteType.YouTube)))
                    {
                        item.IsHasLocalFileFound(DirPath);
                        string title;
                        if (dic.TryGetValue(item.ParentID, out title))
                        {
                            // подсветим видео, если канал уже есть в подписке
                            item.SyncState   = SyncState.Added;
                            item.ParentTitle = title;
                            item.WatchState  = await db.GetItemWatchStateAsync(item.ID).ConfigureAwait(false);
                        }
                        SelectedCountry.Value.Add(item);
                    }
                    RefreshItems();
                }
                break;
            }
        }
        private bool InitSave()
        {
            bool ok = false;

            List <CountryExt> toSaveList   = new List <CountryExt>();
            List <CountryExt> toUpdateList = new List <CountryExt>();

            foreach (var rsn in Countries.ToList())
            {
                if (rsn.ID == 0 && !string.IsNullOrEmpty(rsn.CountryDesc))
                {
                    toSaveList.Add(rsn);
                }
                else if (rsn.ID != 0)
                {
                    toUpdateList.Add(rsn);
                }
            }

            try
            {
                List <Country> addObj = Add(toSaveList);
                if (addObj.Count() > 0)
                {
                    ok = CountryServices.Save(addObj, "Save");
                }

                List <Country> updateObj = Update(toUpdateList);
                if (updateObj.Count() > 0)
                {
                    ok = CountryServices.Save(updateObj, "Update");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Notification", MessageBoxButton.OK);
            }

            return(ok);
        }
Exemple #29
0
        private void SetupUser(Organisation organisation, string email, string firstName, string lastName, string password)
        {
            var userEmail = new EmailAddressBuilder(this.Session).WithElectronicAddressString(email).Build();

            var be = new Countries(this.Session).FindBy(M.Country.IsoCode, "BE");

            var postalAddress = new PostalAddressBuilder(this.Session)
                                .WithAddress1($"{firstName} address")
                                .WithPostalBoundary(new PostalBoundaryBuilder(this.Session).WithLocality($"Mechelen").WithPostalCode("2800").WithCountry(be).Build())
                                .Build();

            var generalCorrespondence = new PartyContactMechanismBuilder(this.Session)
                                        .WithContactMechanism(postalAddress)
                                        .WithContactPurpose(new ContactMechanismPurposes(this.Session).GeneralCorrespondence)
                                        .WithUseAsDefault(true)
                                        .Build();

            var person = new PersonBuilder(this.Session)
                         .WithUserName(email)
                         .WithFirstName(firstName)
                         .WithLastName(lastName)
                         .WithUserEmail(userEmail.ElectronicAddressString)
                         .WithUserEmailConfirmed(true)
                         .WithPartyContactMechanism(generalCorrespondence)
                         .Build();

            person.AddPartyContactMechanism(
                new PartyContactMechanismBuilder(this.Session)
                .WithContactMechanism(userEmail)
                .WithContactPurpose(new ContactMechanismPurposes(this.Session).PersonalEmailAddress)
                .WithUseAsDefault(true)
                .Build());

            new EmploymentBuilder(this.Session).WithEmployee(person).WithEmployer(organisation).Build();

            new UserGroups(this.Session).Administrators.AddMember(person);
            new UserGroups(this.Session).Creators.AddMember(person);

            person.SetPassword(password);
        }
        //[DataMember] private bool? _Favorite;
        public override void DefaultFilters()
        {
            _supressPublish = true;

            Name       = null;
            Player     = null;
            MinPlayers = 0;
            MaxPlayers = 0;
            MaxPing    = 0;
            Mod        = null;

            Continent = null;
            if (Countries == null)
            {
                Countries = new ReactiveList <string>();
                Countries.CollectionChanged += Countries_CollectionChanged;
            }
            else
            {
                Countries.Clear();
            }

            Protection = -1;

            IncompatibleServers = true;
            Modded                = true;
            HideEmpty             = false;
            HideFull              = false;
            HideUnofficial        = false;
            HideNeverJoined       = false;
            HidePasswordProtected = true;
            HideUnresponsive      = false;
            HideWrongGameVersion  = true;

            DefaultMissionFilters();

            _supressPublish = false;

            base.DefaultFilters();
        }
Exemple #31
0
        private async void LoadCountries()
        {
            if (Countries.Any())
            {
                Indicator.IsVisible = false;
            }
            LoadButton.Text = "Atualizando";
            IsBusy          = true;
            List.IsVisible  = true;
            Response.Text   = string.Empty;

            try
            {
                var result = await DataService.GetCountries();

                Countries.Clear();

                foreach (var item in result)
                {
                    Countries.Add(new CountryViewModel(item)
                    {
                        FlagSource    = ImageSource.FromUri(DataService.GetFlagSource(item.Alpha2Code)),
                        BrowseCommand = new Command <CountryViewModel>(BrowseCountry)
                    });
                }
                Response.Text         = string.Empty;
                StatusPanel.IsVisible = false;
            }
            catch (Exception ex)
            {
                Response.Text         = ex.Message;
                StatusPanel.IsVisible = true;
                List.IsVisible        = false;
            }
            finally
            {
                IsBusy          = false;
                LoadButton.Text = "Atualizar";
            }
        }
        public void FilterProcess()
        {
            int count = 0;

            foreach (Process proc in Processes)
            {
                count = Countries.Where(w => w.IsSelected).Count(w => w.Name == proc.Country.Name);
                if (count == 0)
                {
                    proc.IsSelected = false;
                    continue;
                }
                count = Products.Where(w => w.IsSelected).Count(w => w.Name == proc.Product.Name);
                if (count == 0)
                {
                    proc.IsSelected = false;
                    continue;
                }
                count = RAMs.Where(w => w.IsSelected).Count(w => w.Name == proc.RAM.Name);
                if (count == 0)
                {
                    proc.IsSelected = false;
                    continue;
                }
                count = RAEs.Where(w => w.IsSelected).Count(w => w.Name == proc.RAE.Name);
                if (count == 0)
                {
                    proc.IsSelected = false;
                    continue;
                }
                count = ProcessTypes.Where(w => w.IsSelected).Count(w => w.Name == proc.ProcessType.Name);
                if (count == 0)
                {
                    proc.IsSelected = false;
                    continue;
                }

                proc.IsSelected = true;
            }
        }
Exemple #33
0
        public MainWindow(string x, string y)
        {
            InitializeComponent();
            this.Current_Owner.Text = x + " " + y;
            ActualOwner.fName       = x;
            ActualOwner.lName       = y;


            DataContext = new Start_model();


            using (OwnerEntities db = new OwnerEntities())
            {
                ActualOwner.ID = db.Owners.Where(o => o.fName == x).Where(o => o.lName == y).FirstOrDefault().ID;


                if (db.Countries.Count() == 0)
                {
                    foreach (var item in Country.GetValues(typeof(Country)))
                    {
                        Countries c = new Countries()
                        {
                            Country = item.ToString()
                        };
                        db.Countries.Add(c);
                    }
                    db.SaveChanges();
                } // wypełnienie bazy Krajami z enum

                if (db.PhoneBooks.Where(a => a.OwnerID == db.Owners.Where(o => o.fName == ActualOwner.fName).Where(o => o.lName == ActualOwner.lName).FirstOrDefault().ID).Count() == 0)
                {
                    PhoneBooks book = new PhoneBooks()
                    {
                        OwnerID = db.Owners.Where(o => o.fName == ActualOwner.fName).Where(o => o.lName == ActualOwner.lName).First().ID
                    };
                    db.PhoneBooks.Add(book);
                    db.SaveChanges();
                }  //stworzenie książki dla aktualnego usera, jeżeli nie istnieje
            }
        }
        public void ShouldRemoveItemsInCollections()
        {
            SetUp(false);
            RunInUnitOfWork(() =>
            {
                Countries.Put(new TCountry {
                    Name = "Argentina"
                });
                Countries.Put(new TCountry {
                    Name = "USA"
                });
            });

            RunInUnitOfWork(() =>
            {
                var argentina = Countries.GetCountryNamed("Argentina");
                var usa       = Countries.GetCountryNamed("USA");
                argentina.AddCity("Buenos Aires");
                usa.AddCity("Chicago");
                usa.AddCity("New York");
            });

            RunInUnitOfWork(() =>
            {
                var usa = Countries.GetCountryNamed("USA");
                usa.RemoveCity(Cities.GetCityNamed("Chicago"));
            });

            RunInUnitOfWork(() =>
            {
                var argentina = Countries.GetCountryNamed("Argentina");
                var usa       = Countries.GetCountryNamed("USA");

                var argentinaCities = argentina.QueryCities();
                var usaCities       = usa.QueryCities();

                Assert.AreEqual(1, argentinaCities.Count());
                Assert.AreEqual(1, usaCities.Count());
            });
        }
Exemple #35
0
        private void CountriesDeserializeJSON()
        {
            if (!File.Exists(countriesFile))
            {
                throw new FileNotFoundException("JsonFile not found!", countriesFile);
            }

            string parsedJson = File.ReadAllText(countriesFile);

            IEnumerable <Countries> countriesModel = JsonConvert.DeserializeObject <IEnumerable <Countries> >(parsedJson).ToList();

            foreach (var item in countriesModel)
            {
                var newCountries = new Countries()
                {
                    Name = item.Name,
                };
                this.DbPostgreContext.Countries.Add(newCountries);
            }

            this.DbPostgreContext.SaveChanges();
        }
        // POST
        /// <summary>
        /// Add new product. New products should be added with Quantity=0
        /// </summary>
        /// <param name="product">Product to add to database</param>
        public IHttpActionResult Post([FromBody] Products product, string CountryContext = "PLN")
        {
            System.Web.Http.Results.StatusCodeResult status;
            product.Quantity = 0;
            using (IUMdbEntities entities = new IUMdbEntities())
            {
                bool checkIfProductExist = entities.Products.Any(e =>
                                                                 e.ManufacturerName == product.ManufacturerName &&
                                                                 e.ModelName == product.ModelName);

                /*
                 * bool checkIfCountryContextIsSupported = entities.Countries.Any(e =>
                 *  e.CountryTag == CountryContext);
                 */

                if (checkIfProductExist)
                {
                    status = new System.Web.Http.Results.StatusCodeResult(HttpStatusCode.Conflict, this);
                    return(status);
                }

                entities.Products.Add(product);
                entities.SaveChanges();

                Countries requestedCountry = entities.Countries.FirstOrDefault(country => country.CountryTag == CountryContext);
                Prices    price            = new Prices()
                {
                    Price     = product.Price.Value,
                    CountryId = requestedCountry.Id,
                    ProductId = product.Id
                };

                PricesController pc = new PricesController();
                pc.Post(price);

                status = new System.Web.Http.Results.StatusCodeResult(HttpStatusCode.Created, this);
                return(status);
            }
        }
        public async Task <ListCountry> ConsultaCitiesTF(ParamCountry country)
        {
            var query = new GraphQLRequest
            {
                Query     = @"
                query country($country: CountryInput!) {
                      countries(input: $country){
                        list{
                          regions{
                            id
                            name
                            code
                            country
				            cities{
                              id
                              calling_code
                              name
                            }
                          }
                        }
                      }
                }",
                Variables = new { country }
            };

            try
            {
                var response = await _client.PostAsync(query);

                Countries countries = new Countries();

                countries = response.GetDataFieldAs <Countries>("countries");
                return(countries.List[0]);
            }
            catch (Exception)
            {
                return(new ListCountry());
            }
        }
Exemple #38
0
        private void InitializeContacts()
        {
            Contacts = new ObservableCollection <Contact>();
            Country country = Countries.FirstOrDefault(x => x.Code == "BG");
            Company company = Companies.FirstOrDefault(x => x.Id == 1);

            Contacts.Add(new Contact()
            {
                Id        = 1,
                Name      = "Rovaj",
                Surname   = "Vorodot",
                Family    = "Vehsarba",
                Address   = "Sofia",
                ZipCode   = "1000",
                CompanyId = 1,
                Email     = "*****@*****.**",
                Country   = country,
                CountryId = country.Id,
                Phone     = "+35988888888888888",
                Company   = company,
            });
        }
Exemple #39
0
        private void CheckAndClean()
        {
            // Cities with empty regions
            var cityWithEmptyRegion = Cities.FirstOrDefault(city => string.IsNullOrWhiteSpace(city.RegionId) || city.RegionId.All(ch => ch == '0'));

            if (cityWithEmptyRegion != null)
            {
                throw new Exception($"There is '{cityWithEmptyRegion}' city with empty Region");
            }

            // Countries with no regions
            for (int i = Countries.Count - 1; i >= 0; i--)
            {
                Country country = Countries[i];
                var     region  = Regions.FirstOrDefault(r => country.Id.Equals(r.CountryId));
                if (region == null)
                {
                    Countries.RemoveAt(i);
                    Console.WriteLine($"'{country.Name}' has no regions and was deleted");
                }
            }
        }
Exemple #40
0
        public async Task <Response <Countries> > AddCountry(Guid Id, string Country, string IsoCode)
        {
            var listCountryIsoCodes = dbContexts.Countries.Select(c => c.IsoCode).ToList();
            var existingCountry     = await dbContexts.Countries.FirstOrDefaultAsync(c => c.IsoCode == IsoCode.ToString());

            if (existingCountry != null)
            {
                return(new Response <Countries>
                {
                    Message = "The country already exist",
                    Model = existingCountry,
                    Successful = false
                });
            }
            else if (listCountryIsoCodes.Count == 10)
            {
                return(new Response <Countries>
                {
                    Message = "The number of countries exceed the limit of 10",
                    Successful = false
                });
            }
            var newCountry = new Countries()
            {
                ID      = Id,
                Country = Country,
                IsoCode = IsoCode
            };

            dbContexts.Add(newCountry);
            dbContexts.SaveChanges();

            return(new Response <Countries>
            {
                Message = "Successful",
                Model = newCountry,
                Successful = true
            });
        }
Exemple #41
0
 public ActionResult DeleteConfirmed(int id)
 {
     if (Session["User"] != null)
     {
         var user = (Gamification.Models.Users)Session["User"];
         if (user.Role == "Admin")
         {
             Countries countries = db.Countries.Find(id);
             db.Countries.Remove(countries);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Exemple #42
0
        protected void Add_Click(object sender, EventArgs e)
        {
            Countries countries = new Countries();

            countries.companyName = compTxtBox.Text;
            countries.comments    = commentTxtBox.Text;
            List <String> cString = new List <String>();

            foreach (ListItem item in CountriesCBList.Items)
            {
                if (item.Selected == true)
                {
                    cString.Add(item.Text);
                }
            }
            countries.countries = cString.ToArray();
            List <Countries> cList = new List <Countries>();

            cList.Add(countries);
            api.addCompany(cList);
            DisplayAlert("Company Added");
        }
Exemple #43
0
        public ActionResult EditCountry(AddCountry model)
        {
            var   emailid = User.Identity.Name.ToString();
            Users admin   = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault();

            if (ModelState.IsValid)
            {
                Countries obj = dbobj.Countries.Where(x => x.ID == model.CountryID).FirstOrDefault();

                obj.Name         = model.CountryName;
                obj.CountryCode  = model.CountryCode;
                obj.ModifiedDate = DateTime.Now;
                obj.ModifiedBy   = admin.ID;

                dbobj.Entry(obj).State = System.Data.Entity.EntityState.Modified;
                dbobj.SaveChanges();

                return(RedirectToAction("ManageCountries"));
            }
            ViewBag.ProfilePicture = dbobj.Admin.Where(x => x.UserID == admin.ID).Select(x => x.ProfilePicture).FirstOrDefault();
            return(View());
        }
        public void GetISOList()
        {
            //Countries.Initialize();
            var result = Countries.GetIsoList();

            Assert.Equal(255, result.Count());

            foreach (var item in result)
            {
                Assert.NotEmpty(item);
                Assert.Equal(3, item.Length);
            }

            result = Countries.GetIsoList(true);
            Assert.Equal(255, result.Count());

            foreach (var item in result)
            {
                Assert.NotEmpty(item);
                Assert.Equal(2, item.Length);
            }
        }
Exemple #45
0
        public void TestAltSpellings()
        {
            Countries countries = new Countries();
            var       response  = countries.getCountryInfo("true");

            Assert.IsTrue(response.IsSuccessful, "Response isn't success");

            var acceptedList = new List <string>()
            {
                "TR",
                "Turkiye",
                "Republic of Turkey",
                "Türkiye Cumhuriyeti"
            };
            var altSpellings = GetArrayFromResponse(response, "altSpellings");

            var firstNotSecond = acceptedList.Except(altSpellings).ToList();
            var secondNotFirst = altSpellings.Except(acceptedList).ToList();

            Assert.IsTrue(!firstNotSecond.Any());
            Assert.IsTrue(!secondNotFirst.Any());
        }
        private void PageAirports_Loaded(object sender, RoutedEventArgs e)
        {
            Frame frmContent = UIHelpers.FindChild <Frame>(this, "frmContent");

            frmContent.Navigate(new PageShowAirports()
            {
                Tag = this
            });

            var countries = Airports.GetAllAirports().Select(a => new CountryCurrentCountryConverter().Convert(a.Profile.Country) as Country).Distinct().ToList();

            countries.Add(Countries.GetCountry("100"));

            ComboBox cbCountry = UIHelpers.FindChild <ComboBox>(this, "cbCountry");
            ComboBox cbRegion  = UIHelpers.FindChild <ComboBox>(this, "cbRegion");

            cbCountry.ItemsSource = countries.OrderByDescending(c => c.Uid == "100").ThenBy(c => c.Name);

            var regions = countries.Select(c => c.Region).Distinct().ToList().OrderByDescending(r => r.Uid == "100").ThenBy(r => r.Name);

            cbRegion.ItemsSource = regions;
        }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     Countries ds = new Countries();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
Exemple #48
0
 /// <summary>
 /// Create a new Countries object.
 /// </summary>
 /// <param name="countryCode">Initial value of countryCode.</param>
 /// <param name="countryName">Initial value of countryName.</param>
 /// <param name="languageCode">Initial value of languageCode.</param>
 public static Countries CreateCountries(string countryCode, string countryName, string languageCode)
 {
     Countries countries = new Countries();
     countries.countryCode = countryCode;
     countries.countryName = countryName;
     countries.languageCode = languageCode;
     return countries;
 }
Exemple #49
0
 private IList<Countries.City> ReadComuni()
 {
     try
     {
         var comuniProvince = new Countries(this);
         var comuni = comuniProvince.ReadCities();
         return comuni;
     }
     catch (Exception ex)
     {
         UtilityError.Write(ex);
     }
     return null;
 }
    /// <summary>
    /// Thid function loads the dropdown details
    /// </summary>
    void LoadDropDowns()
    {
        // load countries
        var countries = new Countries().GetCountries();
        ddlCountry.Items.Clear();
        ddlBillingCountry.Items.Clear();
        ddlCountry.Items.Add(new ListItem("-please select-", "0"));
        ddlBillingCountry.Items.Add(new ListItem("-please select-", "0"));
        countries.ToList().ForEach(t =>
        {
            ddlCountry.Items.Add(new ListItem(t.Title, Convert.ToString(t.CountryId)));
            ddlBillingCountry.Items.Add(new ListItem(t.Title, Convert.ToString(t.CountryId)));
        });

    }
Exemple #51
0
 public Unit(string texString, int x, int y, int texWidth, int texHeight, Countries country, BlockTypes blockType)
     : base(texString, x, y, texWidth, texHeight)
 {
     _country = country;
     _blockType = blockType;
 }
Exemple #52
0
        private void PopulateServerComboBox(Countries country)
        {
            OGServerComboBox.Enabled = false;
            var list = (from pair in OGameBrowser.GetServerList(country)
                        select new
                        {
                            Name = pair.Key,
                            Url = pair.Value
                        }).ToList();

            OGServerComboBox.DataSource = list;
            OGServerComboBox.DisplayMember = "Name";
            OGServerComboBox.ValueMember = "Url";
            OGServerComboBox.Enabled = true;
        }
Exemple #53
0
        public static PlaceInformation GetPlacesInfo(Countries country, string stateCode, string city)
        {
            var result = new PlaceInformation();

            var returnedJson = Core.ExecuteStraight(country, stateCode, city);
            var o = JObject.Parse(returnedJson);

            result = JsonConvert.DeserializeObject<PlaceInformation>(returnedJson);
            result.CountryCode = (Countries)Enum.Parse(typeof(Countries), (string)o["country abbreviation"]);
            result.PlaceName = (string)o["place name"];
            result.StateCode = (string)o["state abbreviation"];

            var places = (JArray)o["places"];

            for (var i = 0; i < places.Count; i++)
            {
                var newPlace       = new Place();
                newPlace.PlaceName = (string)places[i]["place name"];
                newPlace.Longitude = double.Parse((string)places[i]["longitude"], CultureInfo.InvariantCulture);
                newPlace.Latitude  = double.Parse((string)places[i]["latitude"], CultureInfo.InvariantCulture);
                newPlace.ZipCode   = (string)places[i]["post code"];
                result.Places.Add(newPlace);
            }

            return result;
        }
Exemple #54
0
        public static ZipCodeInfo GetPostalCodeInfo(Countries contry, string zipCode)
        {
            var result = new ZipCodeInfo();

            var returnedJson = Core.ExecuteStraight(contry, zipCode);
            var o = JObject.Parse(returnedJson);

            result = JsonConvert.DeserializeObject<ZipCodeInfo>(returnedJson);
            result.PostalCode = (string)o["post code"];
            result.CountryCode = (Countries)Enum.Parse(typeof(Countries), (string)o["country abbreviation"]);

            var places = (JArray)o["places"];

            for (var i = 0; i < places.Count; i++)
            {
                result.Places.Add(new Place());
                result.Places[i].PlaceName = (string)places[i]["place name"];
                result.Places[i].StateAbbreviation = (string)places[i]["state abbreviation"];
            }

            return result;
        }
Exemple #55
0
 /// <summary>
 /// Executes the straigth request to the API the return will not be format or modify.
 /// </summary>
 /// <param name="country">The country.</param>
 /// <param name="zipcode">The zipcode.</param>
 /// <returns>The coplete received Json.</returns>
 public static string ExecuteStraight(Countries country, string zipcode)
 {
     return ExecuteStraight(country.ToString(), zipcode);
 }
Exemple #56
0
 /// <summary>
 /// Executes the straigth request to the API the return will not be format or modify.
 /// </summary>
 /// <param name="country">The country.</param>
 /// <param name="state">The two letter ISO code of the state.</param>
 /// <param name="city">The city.</param>
 /// <returns>The coplete received Json.</returns>
 public static string ExecuteStraight(Countries country, string state, string city)
 {
     return ExecuteStraight(country.ToString(), state, city);
 }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     Countries ds = new Countries();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "https://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "RegionDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
Exemple #58
0
 /// <summary>
 /// Gets the nearby place with the provided information the return will not be format or modify.
 /// </summary>
 /// <param name="country">The country.</param>
 /// <param name="zipcode">The zipcode.</param>
 /// <returns>The coplete received Json.</returns>
 public static string GetNearbyStraigth(Countries country, string zipcode)
 {
     return ExecuteStraight("nearby", country.ToString(), zipcode, string.Empty);
 }
Exemple #59
0
        /// <summary>
        /// The load country setting.
        /// </summary>
        private static void LoadCountrySetting()
        {
            try
            {
                string path = FileSystemPaths.PathSettings + "Countries.txt";

                if (!File.Exists(path))
                {
                    return;
                }

                string json = IO.ReadTextFromFile(path);
                countries = JsonConvert.DeserializeObject(json, typeof(Countries)) as Countries;
            }
            catch (Exception exception)
            {
                XtraMessageBox.Show("Failed to load Countries settings. Please check log for more info.");
                Log.WriteToLog(LogSeverity.Error, 0, exception.Message, exception.StackTrace);
            }
        }
Exemple #60
0
 /// <summary>Use the following URL templates to get latitude and longitude coordinates for a location by specifying values such as a locality, postal code, and street address.</summary>
 /// <param name="country">A string specifying the ISO country code.</param>
 /// <param name="adminDistrict">A string that contains a subdivision, such as the abbreviation of a US state.</param>
 /// <param name="locality">A string that contains the locality, such as a US city.</param>
 /// <param name="postalCode">A string that contains the postal code, such as a US ZIP Code.</param>
 /// <param name="addressLine">A string specifying the street line of an address.</param>
 /// <param name="userLocation">A point on the earth specified as a latitude and longitude. When you specify this parameter, the user’s location is taken into account and the results returned may be more relevant to the user.</param>
 /// <param name="userIP">The default address is the IPv4 address of the request. When you specify this parameter, the location associated with the IP address is taken into account in computing the results of a location query.</param>
 /// <param name="maxResults">A string that contains an integer between 1 and 20. The default value is 5.</param>
 /// <see cref="http://msdn.microsoft.com/en-us/library/ff701714"/>
 /// <returns>When you make a request by using one of the following URL templates, the response returns one or more Location resources that contain location information associated with the URL parameter values.</returns>
 public async Task<List<Resource>> FindLocationByAddressAsync(Countries country = Countries.US, string adminDistrict = null, string locality = null, string postalCode = null, string addressLine = null, string userLocation = null, string userIP = null, int maxResults = 5)
 {
     var _Template = "http://dev.virtualearth.net/REST/v1/Locations?output=JSON&countryRegion={0}&adminDistrict={1}&locality={2}&postalCode={3}&addressLine={4}&userLocation={5}&userIp={6}&includeNeighborhood=1&maxResults={7}&key={8}";
     var _Url = string.Format(_Template, country.ToString(), adminDistrict, locality, postalCode, addressLine, userLocation, userIP, maxResults, _bingMapsKey);
     var _Result = await CallService(new Uri(_Url));
     if (_Result == null)
         return null;
     return _Result.resourceSets[0].resources;
 }