Esempio n. 1
0
        public CountryListModel GetAllCountries(CountryListModel country)
        {
            CountryListModel countryListModel = new CountryListModel();

            try
            {
                countryListModel.TableCountry = null;
                var CountryList = this.context?.TableCountry.ToList();
                if (CountryList.Count > 0)
                {
                    countryListModel.TableCountry = CountryList;
                }
                countryListModel._tenantName = country._tenantName;
                countryListModel._token      = country._token;
                countryListModel._failure    = false;
            }
            catch (Exception es)
            {
                countryListModel._message    = es.Message;
                countryListModel._failure    = true;
                countryListModel._tenantName = country._tenantName;
                countryListModel._token      = country._token;
            }
            return(countryListModel);
        }
        /// <summary>
        /// Prepare paged country list model
        /// </summary>
        /// <param name="searchModel">Country search model</param>
        /// <returns>Country list model</returns>
        public virtual CountryListModel PrepareCountryListModel(CountrySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get countries
            var countries = _countryService.GetAllCountries(showHidden: true).ToPagedList(searchModel);

            //prepare list model
            var model = new CountryListModel().PrepareToGrid(searchModel, countries, () =>
            {
                //fill in model values from the entity
                return(countries.Select(country =>
                {
                    var countryModel = country.ToModel <CountryModel>();
                    countryModel.NumberOfStates = _stateProvinceService.GetStateProvincesByCountryId(country.Id)?.Count ?? 0;

                    return countryModel;
                }));
            });

            return(model);
        }
        CustomerDefaultModel createCustomerDefault(CompanyModel company)
        {
            if (countryList == null)
            {
                countryList = LookupService.FindCountriesListModel();
            }
            var rnd = RandomInt(0, countryList.Items.Count() - 1);

            var currency = LookupService.FindCurrencyModel(company.DefaultCurrencyID.Value, false);

            var model = new CustomerDefaultModel {
                CompanyId        = company.Id,
                CountryId        = countryList.Items[rnd].Id,
                CountryNameText  = countryList.Items[rnd].CountryName,
                CurrencyId       = currency.Id,
                CurrencyCodeText = currency.CurrencyCode
            };
            var error = CustomerService.InsertOrUpdateCustomerDefault(model);

            Assert.IsTrue(!error.IsError, error.Message);

            countryList.Items.RemoveAt(rnd);    // So we don't use the same country again

            return(model);
        }
Esempio n. 4
0
        public List <CountryListModel> LoadAllCountries()
        {
            List <CountryListModel> allCountries = new List <CountryListModel>();

            SqlConnection sqlConnection = new SqlConnection(connectionString);

            string query = "SELECT * FROM Countries ORDER BY 'Name' ASC";

            SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);

            sqlConnection.Open();

            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

            int sl = 1;

            while (sqlDataReader.Read())
            {
                CountryListModel aCountry = new CountryListModel();
                aCountry.Sl           = sl++;
                aCountry.CountryName  = sqlDataReader["Name"].ToString();
                aCountry.CountryAbout = sqlDataReader["About"].ToString();
                allCountries.Add(aCountry);
            }
            sqlConnection.Close();
            return(allCountries);
        }
Esempio n. 5
0
        /// <summary>
        /// Prepare paged country list model
        /// </summary>
        /// <param name="searchModel">Country search model</param>
        /// <returns>Country list model</returns>
        public virtual CountryListModel PrepareCountryListModel(CountrySearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get countries
            var countries = _countryService.GetAllCountries(showHidden: true);

            //prepare list model
            var model = new CountryListModel
            {
                //fill in model values from the entity
                Data = countries.PaginationByRequestModel(searchModel).Select(country =>
                {
                    var countryModel            = country.ToModel <CountryModel>();
                    countryModel.NumberOfStates = country.StateProvinces?.Count ?? 0;

                    return(countryModel);
                }),
                Total = countries.Count
            };

            return(model);
        }
Esempio n. 6
0
        public CountryListModel FindCountriesListModel(int index = 0, int pageNo = 1, int pageSize = Int32.MaxValue, string search = "")
        {
            var model = new CountryListModel();

            int  numValue = 0;
            bool bGotNum  = int.TryParse(search, out numValue);

            // Do a case-insensitive search
            model.GridIndex = index;
            var allItems = db.FindCountries(true)
                           .Where(c => string.IsNullOrEmpty(search) ||
                                  (c.CountryName != null && c.CountryName.ToLower().Contains(search.ToLower())) ||
                                  (c.ISO2Code != null && c.ISO2Code.ToLower().Contains(search.ToLower())) ||
                                  (c.ISO3Code != null && c.ISO3Code.ToLower().Contains(search.ToLower())) ||
                                  (bGotNum && c.UNCode == numValue));

            model.TotalRecords = allItems.Count();
            model.Items        = allItems.Skip((pageNo - 1) * pageSize)
                                 .Take(pageSize)
                                 .Select(c => new CountryModel {
                Id          = c.Id,
                CountryName = c.CountryName,
                ISO2Code    = c.ISO2Code,
                ISO3Code    = c.ISO3Code,
                UNCode      = c.UNCode,
                Enabled     = c.Enabled
            }).ToList();
            return(model);
        }
Esempio n. 7
0
        public ActionResult Index()
        {
            n++;
            WorldCupDbEntities db = new WorldCupDbEntities();

            if (db.Countries.SingleOrDefault(x => x.Country_Id == n) != null)
            {
                Country          Ct = db.Countries.SingleOrDefault(x => x.Country_Id == n);
                CountryListModel lm = new CountryListModel();
                lm.Country_Id = Ct.Country_Id;
                lm.Name       = Ct.Name;


                if (db.Scorers.FirstOrDefault(x => x.Country_Id == n) != null)
                {
                    foreach (Scorer xx in db.Scorers)
                    {
                        if (xx.Country_Id == n)
                        {
                            lm.Scorer_Id.Add(xx.Scorer_Id);
                            lm.Surname.Add(xx.Surname);
                            lm.counter++;
                        }
                    }
                }



                return(View(lm));
            }
            else if (db.Countries.First() != null)
            {
                Country          Ct = db.Countries.First();
                CountryListModel lm = new CountryListModel();
                lm.Country_Id = Ct.Country_Id;
                lm.Name       = Ct.Name;
                n             = Ct.Country_Id;

                if (db.Scorers.FirstOrDefault(x => x.Country_Id == n) != null)
                {
                    foreach (Scorer xx in db.Scorers)
                    {
                        if (xx.Country_Id == n)
                        {
                            lm.Scorer_Id.Add(xx.Scorer_Id);
                            lm.Surname.Add(xx.Surname);
                            lm.counter++;
                        }
                    }
                }


                return(View(lm));
            }
            else
            {
                return(View());
            }
        }
Esempio n. 8
0
        public IActionResult CountryList(int page = 1, int size = 20, string keyword = null, bool?status = null)
        {
            var model = new CountryListModel();

            model.Keyword   = keyword;
            model.Countries = DefaultStorage.CountryPagedList(page, size, keyword, status);
            return(View(model));
        }
        public ActionResult List()
        {
            var allStores = _services.StoreService.GetAllStores();

            var model = new CountryListModel
            {
                StoreCount = allStores.Count
            };

            return(View(model));
        }
        public async Task <IActionResult> Index()
        {
            var countries = await _countryAppService.GetAll();

            var model = new CountryListModel()
            {
                Countries = countries
            };

            return(View(model));
        }
Esempio n. 11
0
        public ActionResult Delete(int index, int id)
        {
            var model = new CountryListModel();

            model.GridIndex = index;
            try {
                LookupService.DeleteCountry(id);
            } catch (Exception e1) {
                model.Error.SetError(e1);
            }
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Esempio n. 12
0
        public ActionResult <CountryListModel> GetAllCountries(CountryListModel country)
        {
            CountryListModel countryListModel = new CountryListModel();

            try
            {
                countryListModel = _commonService.GetAllCountries(country);
            }
            catch (Exception es)
            {
                countryListModel._failure = true;
                countryListModel._message = es.Message;
            }
            return(countryListModel);
        }
Esempio n. 13
0
        public ActionResult List()
        {
            if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageCountries))
            {
                return(AccessDeniedView());
            }

            var allStores = _services.StoreService.GetAllStores();

            var model = new CountryListModel
            {
                StoreCount = allStores.Count
            };

            return(View(model));
        }
Esempio n. 14
0
        public CountryListModel GetAllCountries(CountryListModel country)
        {
            CountryListModel countryListModel = new CountryListModel();
            if (TokenManager.CheckToken(country._tenantName, country._token))
            {
                countryListModel = this.commonRepository.GetAllCountries(country);
                return countryListModel;
            }
            else
            {
                countryListModel._failure = true;
                countryListModel._message = TOKENINVALID;
                return countryListModel;
            }

        }