public async Task <IActionResult> Index(Guid id)
        {
            var addresses = await _addressAppService.GetAllByCustomerIdIncluding(id);

            var provinces = await _provinceAppService.GetAll();

            var countries = await _countryAppService.GetAll();

            if (!countries.Any())
            {
                throw new Exception("No countries found!");
            }

            IEnumerable <SelectListItem> selectListCountries = countries.Select(x => new SelectListItem {
                Text = L(x.Name), Value = x.Id.ToString()
            }).ToList();
            IEnumerable <SelectListItem> selectListProvinces = provinces.Where(x => x.CountryId == countries.First().Id).Select(x => new SelectListItem {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();

            var addressViewModel = new AddressListModel()
            {
                CustomerId = id,
                Addresses  = addresses,
                Countries  = selectListCountries,
                Provinces  = selectListProvinces
            };

            return(View(addressViewModel));
        }
        public async Task <IActionResult> Index()
        {
            var provinces = await _provinceAppService.GetAll();

            var countries = await _countryAppService.GetAll();

            IEnumerable <SelectListItem> selectList = countries.Select(x => new SelectListItem {
                Text = L(x.Name), Value = x.Id.ToString()
            }).ToList();
            var model = new ProvinceListModel()
            {
                Provinces = provinces,
                Countries = selectList
            };

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

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

            return(View(model));
        }
Exemple #4
0
 public IActionResult Get()
 {
     try
     {
         return(Ok(_appService.GetAll()));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
        public async Task <CompanyListModel> PrepareCompanyModel()
        {
            var provinces = await _provinceAppService.GetAll();

            var countries = await _countryAppService.GetAll();

            var companies = await _companyAppService.GetAll();

            IEnumerable <SelectListItem> selectListCountry = countries.Select(x => new SelectListItem {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();
            IEnumerable <SelectListItem> selectListProvince = provinces.Select(x => new SelectListItem {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();
            var model = new CompanyListModel()
            {
                Provinces = selectListProvince,
                Countries = selectListCountry,
                Companies = companies
            };

            return(model);
        }