public ActionResult Create()
        {
            List <SelectListItem> areaList = new List <SelectListItem>();
            List <SelectListItem> cityList = new List <SelectListItem>();

            foreach (Area area in areaRepo.GetAll())
            {
                SelectListItem option = new SelectListItem();
                option.Text  = area.Name;
                option.Value = area.Id.ToString();

                areaList.Add(option);
            }

            foreach (City city in cityRepo.GetAll())
            {
                SelectListItem option = new SelectListItem();
                option.Text  = city.Name;
                option.Value = city.Id.ToString();

                cityList.Add(option);
            }

            ViewBag.Area = areaList;
            ViewBag.City = cityList;

            return(View());
        }
Exemple #2
0
        public async Task <ActionResult> Settings()
        {
            var user = await userMgr.FindByNameAsync(User.Identity.Name);

            var model = new ProfileSettingsViewModel
            {
                FirstName = user.FirstName,
                LastName  = user.LastName,
                Birthday  = user.Birthday
            };

            List <CinemaEntity> listCinema = new List <CinemaEntity> {
                new CinemaEntity {
                    Id = 0, Name = "Не вибрано"
                }
            };

            listCinema.AddRange(cinemaRepository.GetAll());
            List <City> listCity = new List <City> {
                new City {
                    Id = 0, Name = "Не вибрано"
                }
            };

            listCity.AddRange(cityRepository.GetAll());
            int userFavoriteCinema = (user.FavotiteCinema == null) ? 0 : user.FavotiteCinema.Id;
            int userCity           = (user.City == null) ? 0 : user.City.Id;

            ViewBag.FavoriteCinemaId = new SelectList(listCinema, "id", "name", userFavoriteCinema);
            ViewBag.CityId           = new SelectList(listCity, "id", "name", userCity);

            return(View(model));
        }
        public ActionResult CityListPartial()
        {
            List <City> city = cityRepo.GetAll();

            ViewBag.CityList = city;
            return(View());
        }
Exemple #4
0
        // GET: Demo
        public ActionResult Index()
        {
            var city = cityRepository.GetAll();
            IEnumerable <SelectListItem> items1 = city.Select(c => new SelectListItem
            {
                Value = (c.CityId).ToString(),
                Text  = c.CityName
            });

            ViewBag.CityList = items1;
            return(View());
        }
Exemple #5
0
        public ActionResult Edit(int id = 0)
        {
            // add the Cities to the Viewbag
            CityRepository cityRepository = new CityRepository();
            List <City>    allCities      = cityRepository.GetAll();

            ViewBag.AllCities = new SelectList(allCities, "ID", "Name");

            // add the Categories to the Viewbag
            CategoryRepository categoryRepository = new CategoryRepository();
            List <Category>    allCategories      = categoryRepository.GetAll();

            ViewBag.AllCategories = new SelectList(allCategories, "ID", "Name");

            // create the viewmodel, based on the Restaurant from the database
            RestaurantViewModel  model = new RestaurantViewModel();
            RestaurantRepository restaurantRepository = new RestaurantRepository();
            Restaurant           dbRestaurant         = restaurantRepository.GetByID(id);

            if (dbRestaurant != null)
            {
                model = new RestaurantViewModel(dbRestaurant);
            }
            return(View(model));
        }
Exemple #6
0
        private List <DistrictInformationViewModel> SearchDistrict(string keyword, string cityName)
        {
            var cityRepo     = new CityRepository();
            var districtRepo = new DistrictRepository();

            var allCities    = cityRepo.GetAll();
            var allDistricts = districtRepo.GetAll();

            var query = from d in allDistricts
                        join c in allCities on d.CityCode equals c.Code
                        select new DistrictInformationViewModel()
            {
                DistrictCode = d.Code, DistrictName = d.Name, CityName = c.Name
            };

            if (!string.IsNullOrEmpty(keyword))
            {
                keyword = keyword.ToLower();
                query   = query.Where(x => x.DistrictName.ToLower().Contains(keyword) || x.DistrictCode.ToLower().Contains(keyword)).ToList();
            }
            if (!string.IsNullOrEmpty(cityName))
            {
                cityName = cityName.ToLower();
                query    = query.Where(x => x.CityName.ToLower().Contains(cityName)).ToList();
            }

            var result = query.ToList();

            return(result);
        }
        public AbstractDomainModel GetAll(SearchCriteriaEnum searchCriteria)
        {
            DomainModel.Models.EditProfile editProfile = new DomainModel.Models.EditProfile();

            switch (searchCriteria)
            {
            case CareHub.Core.Enumerations.SearchCriteriaEnum.GET_COUNTRIES:
                editProfile.Countries = countryRepository.GetAll();
                break;

            case CareHub.Core.Enumerations.SearchCriteriaEnum.GET_STATES:
                editProfile.States = stateRepository.GetAll();
                break;

            case CareHub.Core.Enumerations.SearchCriteriaEnum.GET_CITIES:
                editProfile.Cities = cityRepository.GetAll();
                break;

            case CareHub.Core.Enumerations.SearchCriteriaEnum.GET_LOCALITIES:
                editProfile.Localities = localityRepository.GetAll();
                break;

            default:
                break;
            }
            return(editProfile);
        }
Exemple #8
0
 public async Task <CityDTO[]> Get()
 {
     using (var repo = new CityRepository())
     {
         return((await repo.GetAll()).Select(x => new CityDTO(x)).ToArray());
     }
 }
Exemple #9
0
        public AbstractDomainModel GetAll(SearchCriteriaEnum searchCriteria)
        {
            DomainModel.Models.ProviderRegistration providerRegistration = new DomainModel.Models.ProviderRegistration();

            switch (searchCriteria)
            {
            case CareHub.Core.Enumerations.SearchCriteriaEnum.GET_SPECIALTIES:
                providerRegistration.Specialties = specialtyRepository.GetAll();
                break;

            case CareHub.Core.Enumerations.SearchCriteriaEnum.GET_COUNTRIES:
                providerRegistration.Countries = countryRepository.GetAll();
                break;

            case CareHub.Core.Enumerations.SearchCriteriaEnum.GET_CITIES:
                providerRegistration.Cities = cityRepository.GetAll();
                break;

            case CareHub.Core.Enumerations.SearchCriteriaEnum.GET_LOCALITIES:
                providerRegistration.Localities = localityRepository.GetAll();
                break;

            default:
                break;
            }
            return(providerRegistration);
        }
        public void RemoveTest()
        {
            CityRepository cr = new CityRepository();

            var p = cr.GetAll().GetEnumerator();

            p.MoveNext();

            Cep item = new Cep()
            {
                CEP = "00000001", Logradouro = "Logradouro01", Bairro = "Bairro01", Cidade = p.Current
            };
            IZipCodeRepository target = new ZipCodeRepository();

            target.Add(item);
            target.Remove(item);

            // use session to try to load the product
            using (ISession session = NHibernateHelper.OpenSession())
            {
                var fromDb = session.Get <Cep>(item.Id);

                Assert.IsNull(fromDb);
                Assert.AreNotSame(item, fromDb);
            }
        }
Exemple #11
0
        public ActionResult Index()
        {
            if (string.IsNullOrEmpty(User.Identity.Name))
            {
                return(RedirectToAction("Login", "Account"));
            }

            using (UserRepository user = new UserRepository())
            {
                ViewBag.IsAdmin = user.IsAdmin(User.Identity.Name);
            }

            ViewBag.Title = "Customer List";

            CustomerViewModel model = new CustomerViewModel();

            using (GenderRepository gender = new GenderRepository())
                model.Genders = gender.GetAll();

            using (RegionRepository region = new RegionRepository())
                model.Regions = region.GetAll();

            using (CityRepository city = new CityRepository())
                model.Cities = city.GetAll();

            using (ClassificationRepository classification = new ClassificationRepository())
                model.Classifications = classification.GetAll();

            using (UserRepository user = new UserRepository())
                model.Sellers = user.GetAll();

            return(View(model));
        }
        public void GetAll_ShouldReturnAllCitiesFromDatabase()
        {
            //Arrange
            var allOriginalCities = GetAllCities();

            //Act
            var retrievedCities = _repository.GetAll();

            //Assert
            Assert.That(retrievedCities, Is.Not.Null,
                        () => "The method returns null while there are cities in the database.");
            Assert.That(retrievedCities.Count, Is.EqualTo(allOriginalCities.Count),
                        () => "Not all cities in the database are returned.");

            foreach (var retrievedCity in retrievedCities)
            {
                var matchingOriginal =
                    allOriginalCities.FirstOrDefault(city =>
                                                     city.ZipCode == retrievedCity.ZipCode);

                Assert.That(matchingOriginal, Is.Not.Null,
                            () => "The 'ZipCode' property of one or more cities is not correct.");
                Assert.That(retrievedCity.Name, Is.EqualTo(matchingOriginal.Name),
                            () => "The 'Name' property of one or more cities is not correct.");
            }
        }
        public void GetByIdTest()
        {
            CityRepository cr = new CityRepository();
            var            p  = cr.GetAll().GetEnumerator();

            p.MoveNext();

            Cep item = new Cep()
            {
                CEP = "00000001", Logradouro = "Logradouro01", Bairro = "Bairro01", Cidade = p.Current
            };
            IZipCodeRepository target = new ZipCodeRepository();

            target.Add(item);

            try
            {
                var fromDb = target.GetById(item.Id);

                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(item, fromDb);
                Assert.AreEqual(item.CEP, fromDb.CEP);
                Assert.AreEqual(item.Logradouro, fromDb.Logradouro);
                Assert.AreEqual(item.Bairro, fromDb.Bairro);
                Assert.IsNotNull(fromDb.Cidade);
                Assert.AreEqual(item.Cidade.Id, fromDb.Cidade.Id);
            }
            finally
            {
                target.Remove(item);
            }
        }
        public ActionResult EditStore(int id = 0)
        {
            if (!LoginUserSession.Current.IsAdministrator)
            {
                return(RedirectToAction("Edit"));
            }

            CityRepository cityRepo = new CityRepository();

            List <City> cities = cityRepo.GetAll();

            ViewBag.Cities = new SelectList(cities, "ID", "Name");

            StoreRepository repo = new StoreRepository();

            StoreViewModel store = new StoreViewModel();

            Store storeDb = repo.GetByID(id);

            if (storeDb != null)
            {
                store = new StoreViewModel(storeDb);
            }

            return(View(store));
        }
Exemple #15
0
        public ActionResult Edit()
        {
            CityRepository repo = new CityRepository();

            CityViewModel model = new CityViewModel(repo.GetAll());

            return(View(model));
        }
 //
 // GET: /City/
 public ActionResult Index()
 {
     if (Session["username"] == null)
     {
         return(RedirectToAction("Login", "Home"));
     }
     return(View(ICR.GetAll()));
 }
Exemple #17
0
        public ActionResult Edit(int id)
        {
            int StateId = id;
            var product = productRepository.GetById(StateId);

            var CountryList  = countryRepository.GetAll().ToList();
            var StateList    = stateRepository.GetAll().ToList();
            var CityList     = cityRepository.GetAll().ToList();
            var CategoryList = categoryRepository.GetAll().ToList();

            //Creating ViewBag named BrandListItem to used in VIEW.
            ViewBag.CountryList  = ToSelectList(CountryList);
            ViewBag.StateList    = ToSelectListState(StateList);
            ViewBag.CityList     = ToSelectListCity(CityList);
            ViewBag.CategoryList = ToSelectListCategory(CategoryList);
            return(View(product));
        }
Exemple #18
0
        public ActionResult Index()
        {
            CityListVM model = new CityListVM();

            model.Cities = CityRepository.GetAll();

            return(View(model));
        }
Exemple #19
0
 public void ListarCidades()
 {
     try
     {
         var repo   = new CityRepository(config);
         var result = repo.GetAll();
     }
     catch (Exception) { Assert.Fail(); }
 }
Exemple #20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public List <CityModel> GetCitys()
        {
            var items = CityRepository.GetAll();

            if (items != null)
            {
                return(items.Select(p => p.ToModel()).ToList());
            }
            return(new List <CityModel>());
        }
        public void GetAllCities_TestMethod()
        {
            //Arrange
            CityRepository repository = new CityRepository(databaseConnection);

            // Act
            var cityList = repository.GetAll();

            //Assert
            Assert.IsTrue(cityList.ToList().Count != 0);
        }
        public ActionResult Create()
        {
            var categories = _categoryRepository.GetAll();
            var cities     = _cityRepository.GetAll();

            RestaurantCreateVM model = new RestaurantCreateVM();

            PrepareDropdowns(model.Categories, model.Cities, categories, cities);

            return(View(model));
        }
        public List <CityDTO> GetAllCities()
        {
            List <CityDTO> cityDTOs = new List <CityDTO>();
            List <City>    cities   = _cityRepository.GetAll();

            foreach (var item in cities)
            {
                cityDTOs.Add(_mapper.Mapper().Map <CityDTO>(item));
            }
            return(cityDTOs);
        }
Exemple #24
0
 public List<CityModel> GetAllCiites()
 {
     //unitOfWork.StartTransaction();
     CityRepository repo = new CityRepository(unitOfWork);
     List<CityModel> cityModelList = new List<CityModel>();
     List<City> cityList = new List<City>();
     AutoMapper.Mapper.Map(cityModelList, cityList);
     cityList = repo.GetAll().OrderByDescending(x=>x.CityId).ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(cityList, cityModelList);
     return cityModelList;
 }
Exemple #25
0
 public CityModel GetCityById(int cityId)
 {
     //unitOfWork.StartTransaction();
     CityRepository repo = new CityRepository(unitOfWork);
     CityModel cityModel = new CityModel();
     City city = new City();
     AutoMapper.Mapper.Map(cityModel, city);
     city = repo.GetAll().Where(x => x.CityId == cityId).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(city, cityModel);
     return cityModel;
 }
        public void GetAll_Test()
        {
            // Arrange
            TestKolgraphEntities context = new TestKolgraphEntities();
            var repository = new CityRepository(context);

            // Act
            IEnumerable <city> result = repository.GetAll();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(context.city.Count(), result.Count());
        }
Exemple #27
0
        public JsonResult ShowSearch()
        {
            //ViewBag.Period = _periodRepository.GetAll().Data
            //                                    .Select(i => new SelectListItem()
            //                                    {
            //                                        Text = i.YearFrom.ToString() + " - " + i.YearTo.ToString(),
            //                                        Value = i.PeriodId.ToString()
            //                                    });

            //ViewBag.Grade = _gradeRepository.GetAll(0).Data
            //                                    .Select(i => new SelectListItem()
            //                                    {
            //                                        Text =i.GradeDescription,
            //                                        Value = i.GradeId.ToString()
            //                                    });

            ViewBag.Gender = _genderRepository.GetAll().Data
                             .Select(i => new SelectListItem()
            {
                Text  = i.GenderDescription,
                Value = i.GenderId.ToString()
            });

            ViewBag.City = _cityRepository.GetAll().Data
                           .Select(i => new SelectListItem()
            {
                Text  = i.CityDescription,
                Value = i.CityId.ToString()
            });

            return(Json(new
            {
                Html = RenderPartial.RenderPartialView(this, "~/Views/Student/_search.cshtml", null),

                Message = "",
                Status = "OK"
            }, JsonRequestBehavior.AllowGet));
        }
Exemple #28
0
        public async Task <IEnumerable <CityDto> > GetCitiesAsync()
        {
            try
            {
                var cities = (await _cityRepository.GetAll())
                             .OrderBy(x => x.Name);

                return(_mapper.Map <IEnumerable <CityDto> >(cities));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #29
0
 public bool CheckExistance(int cityId)
 {
     //unitOfWork.StartTransaction();
     CityRepository repo = new CityRepository(unitOfWork);
     var city = repo.GetAll().Where(x => x.CityId == cityId).Count();
     //unitOfWork.Commit();
     if (city > 0)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Exemple #30
0
        private List <DistrictViewModel> GetDistrictInformations(string keyword, string cityCode)
        {
            var allDistricts = _districtRepository.GetAll();
            var allCities    = _cityRepository.GetAll();

            var query = from d in allDistricts
                        join c in allCities on d.CityCode equals c.Code
                        select new DistrictViewModel {
                DistrictCode = d.Code, DistrictName = d.Name, CityCode = c.Code, CityName = c.Name
            };

            if (!string.IsNullOrEmpty(keyword))
            {
                keyword = keyword.ToLower();
                query   = query.Where(a => a.DistrictCode.ToLower().Contains(keyword) || a.DistrictName.ToLower().Contains(keyword));
            }

            if (!string.IsNullOrEmpty(cityCode))
            {
                query = query.Where(a => a.CityCode.Contains(cityCode));
            }

            return(query.ToList());
        }
        public void CityRepository_GetAll_All()
        {
            // Arrange
            CityRepository cityRepo = new CityRepository(mockContext.Object);
            // Act
            List <City> listCities = cityRepo.GetAll().ToList();

            // Assert all objects from the List
            for (int i = 0; i < listCities.Count; i++)
            {
                Assert.AreEqual(citiesProvider[i].CityName, listCities[i].CityName);
                // Preview Test results in Test->Debug mode:
                Console.WriteLine($"Data Provider: {citiesProvider[i].CityName}, " +
                                  $"Repository: {listCities[i].CityName}");
            }
        }
Exemple #32
0
        static void Main(string[] args)
        {
            var city = new City()
            {
                CityCode = "123",
                CityName = "teste"
            };

            var repo = new CityRepository();

            repo.Add(city);

            var all = repo.GetAll();

            Console.WriteLine($"cities: {all.Count()}");
        }
        private void LoadCities(string selectedCityCode = "")
        {
            var cities = _cityRepository.GetAll();

            cbbCity.DataSource    = cities;
            cbbCity.DisplayMember = nameof(City.Name);

            if (!string.IsNullOrEmpty(selectedCityCode))
            {
                var selectedCity = cities.FirstOrDefault(x => x.Code == selectedCityCode);
                if (selectedCity != null)
                {
                    cbbCity.SelectedItem = selectedCity;
                }
            }
        }
Exemple #34
0
 public CityModel UpadteCity(CityModel model)
 {
     //unitOfWork.StartTransaction();
     CityRepository repo = new CityRepository(unitOfWork);
     City city = new City();
     city = repo.GetAll().Where(x => x.CityId == model.CityId).FirstOrDefault();
     AutoMapper.Mapper.Map(model, city);
     repo.Update(city);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(city, model);
     return model;
 }