Esempio n. 1
0
        ////
        //City Methods
        ////

        #region City



        public async Task <IActionResult> CityIndex(string search = "")
        {
            List <CityListViewModel> model = new List <CityListViewModel>();
            var dbData = await _unitOfWork.Repository <City>().GetAllIncludeAsync(x => x.Country, l => l.Locations);

            if (!String.IsNullOrEmpty(search))
            {
                dbData = dbData.Where(x => x.Name.ToLower().Contains(search.ToLower())).ToList();
                ViewBag.SearchString = search;
            }

            foreach (var b in dbData)
            {
                CityListViewModel city = new CityListViewModel
                {
                    Id            = b.Id,
                    Name          = b.Name,
                    TotalLocation = b.Locations?.Count ?? 0,
                    CountryId     = b.CountryId,
                    CountryName   = b.Country.Name,
                };
                model.Add(city);
            }

            return(View(model));
        }
Esempio n. 2
0
        public ActionResult CityList()
        {
            CityListViewModel model = new CityListViewModel();

            model.Cities = _cityManager.List();

            return(View(model));
        }
Esempio n. 3
0
        public async Task <IActionResult> Index(CityListViewModel model)
        {
            var currentPageNum = model.Page;
            var offset         = (model.PageSize * currentPageNum) - model.PageSize;
            //Convert list to generic IEnumerable using AsQueryable
            var cities = CommonContext.Cities.AsQueryable();


            if (!string.IsNullOrWhiteSpace(model.Name))
            {
                cities = cities.Where(x => x.Name.ToLower().Contains(model.Name.ToLower()));
            }
            if (!string.IsNullOrWhiteSpace(model.State))
            {
                cities = cities.Where(x => x.State.ToLower().Contains(model.State.ToLower()));
            }

            switch (model.SortOrder)
            {
            case "Name":
                if (model.SortDirection == "DESC")
                {
                    cities = cities.OrderByDescending(x => x.Name);
                }
                else
                {
                    cities = cities.OrderBy(x => x.Name);
                }
                break;

            case "State":
                if (model.SortDirection == "DESC")
                {
                    cities = cities.OrderByDescending(x => x.State);
                }
                else
                {
                    cities = cities.OrderBy(x => x.State);
                }
                break;

            default:
                cities = cities.OrderByDescending(x => x.CreateUtc);
                break;
            }

            model.Paging.TotalItems = await cities.CountAsync();

            model.CityList = Mapper.Map <List <CityListItem> >(await cities.Skip(offset).Take(model.PageSize).ToListAsync());

            model.Paging.CurrentPage  = currentPageNum;
            model.Paging.ItemsPerPage = model.PageSize;

            return(View(model));
        }
Esempio n. 4
0
 public CityController(IViewService viewService, IEntityService entityService, CityListViewModel cityListViewModel, CityViewModel cityViewModel, ExportFactory <ProvinceSelectorViewModel> provinceSelectorViewModelFactory)
 {
     _viewService       = viewService;
     _entityService     = entityService;
     _cityListViewModel = cityListViewModel;
     _cityViewModel     = cityViewModel;
     _provinceSelectorViewModelFactory = provinceSelectorViewModelFactory;
     _addNewCommand         = new DelegateCommand(AddNewCity_OnExecute, AddNewCity_OnCanExecute);
     _removeCommand         = new DelegateCommand(RemoveCity_OnExecute, RemoveCity_OnCanExecute);
     _selectProvinceCommand = new DelegateCommand(c => SelectProvince_OnExecute((CityEntity)c));
 }
Esempio n. 5
0
        // GET: Home
        public ActionResult Index()
        {
            CityListViewModel model;

            using (var context = new ApplicationDbContext())
            {
                model = new CityListViewModel
                {
                    CityList = context.Cities.ToList()
                };
            }
            return(View(model));
        }
        public IActionResult Index(int page)
        {
            List <City> cityList = GetCityList(); // Get dummy data.

            CityListViewModel cityListmodel = new CityListViewModel()
            {
                CityList      = cityList.Skip((page - 1) * pageSize).Take(pageSize).ToList(),
                CurrentPageNo = page,
                PageCount     = (int)Math.Ceiling(cityList.Count / (double)pageSize),
                PageSize      = pageSize
            };

            return(View(cityListmodel));
        }
Esempio n. 7
0
        public async Task <IActionResult> Index()
        {
            this.ViewData["ReturnUrl"] = "/BuyTicket/Index";
            var cities = await GetCitiesCached();

            var projections = await GetTopProjectionsCached(3);

            this.ViewBag.DefaultImage = defaultImage;

            var topProjections = new TopProjectionsViewModel(projections.Select(p => new ProjectionViewModel(p, defaultImage)));

            var model = new CityListViewModel(cities.Select(city => new CityViewModel(city)), topProjections);

            return(View(model));
        }
        /// <summary>
        /// Represents an index action.
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            CityListViewModel vm = new CityListViewModel();

            var codes = _dao.GetCountryCodes();

            foreach (var code in codes)
            {
                SelectListItem item = new SelectListItem();
                item.Text = code;
                vm.CountryCodes.Add(item);
            }

            return(View(vm));
        }
Esempio n. 9
0
        public ActionResult GetCityEditListByAreaId(int areaId)
        {
            var citiesResult = _cityService.GetCitiesByAreaId(areaId);

            if (citiesResult.IsSuccess())
            {
                var cities        = citiesResult.GetSuccessResult();
                var cityListModel = new CityListViewModel
                {
                    AreaId = areaId,
                    Cities = cities
                };

                return(PartialView("CityEditList", cityListModel));
            }
            return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
        }
        public IActionResult Detail(CityListViewModel vm)
        {
            CityDetailViewModel detailViewModel = new CityDetailViewModel();

            detailViewModel.Cities     = _dao.GetCities(vm.CountryCode, vm.District);
            detailViewModel.CityListVM = vm;

            var codes = _dao.GetCountryCodes();

            foreach (var code in codes)
            {
                SelectListItem item = new SelectListItem();
                item.Text = code;
                detailViewModel.CityListVM.CountryCodes.Add(item);
            }

            return(View(detailViewModel));
        }
Esempio n. 11
0
 public CityListPage()
 {
     BindingContext = new CityListViewModel(new Navigations());
     InitializeComponent();
 }