コード例 #1
0
        // GET: Pais/Edit/5
        public async Task <IActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            HttpResponseMessage response = await _httpClient.GetAsync($"pais/{id}");

            if (response.IsSuccessStatusCode)
            {
                PaisView pais = await response.Content.ReadAsAsync <PaisView>();

                if (pais == null)
                {
                    return(NotFound());
                }

                return(View(pais));
            }
            else
            {
                return(NotFound());
            }
        }
コード例 #2
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Nome,LogoFile")] PaisView pais)
        {
            if (id != pais.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    string urlLogo = _serviceUpload.Upload(pais.LogoFile);
                    pais.FotoBandeira = urlLogo;
                    await _httpClient.PutAsJsonAsync($"pais", pais);

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!await PaisExists(pais.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(View(pais));
        }
コード例 #3
0
ファイル: PaisesController.cs プロジェクト: ats93/ASP.NET
        // GET: Ciudades
        public ActionResult Index()
        {
            IPaisDAO dao = new PaisDAO();

            paises      = new List <Pais>();
            ciudades    = new List <Ciudad>();
            paises      = dao.GetPaises();
            view        = new PaisView();
            view.paises = paises;
            return(View(view));
        }
コード例 #4
0
ファイル: PaisesController.cs プロジェクト: ats93/ASP.NET
        public ActionResult GetCiudades(int id)
        {
            ICiudadDAO dao  = new CiudadDAO();
            IPaisDAO   pDao = new PaisDAO();

            ciudades      = dao.GetCiudades().Where(o => o.PaisId == id).ToList();
            view          = new PaisView();
            paises        = pDao.GetPaises();
            view.paises   = paises;
            view.ciudades = ciudades;
            return(View("DropDownPartial", view));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("Id,Nome,LogoFile")] PaisView pais)
        {
            if (ModelState.IsValid)
            {
                string urlLogo = _serviceUpload.Upload(pais.LogoFile);
                pais.FotoBandeira = urlLogo;
                HttpResponseMessage response = await _httpClient.PostAsJsonAsync($"pais", pais);

                if (response.IsSuccessStatusCode)
                {
                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(pais));
        }