// GET: Estado/Delete/5 public async Task <IActionResult> Delete(string id) { if (id == null) { return(NotFound()); } HttpResponseMessage responseEstado = await _httpClient.GetAsync($"estado/{id}"); if (responseEstado.IsSuccessStatusCode) { EstadoView estado = await responseEstado.Content.ReadAsAsync <EstadoView>(); if (estado == null) { return(NotFound()); } HttpResponseMessage responsePais = await _httpClient.GetAsync($"pais/{estado.PaisId}"); if (responsePais.IsSuccessStatusCode) { estado.Pais = await responsePais.Content.ReadAsAsync <PaisView>(); return(View(estado)); } return(NotFound()); } else { return(NotFound()); } }
public async Task <IActionResult> Edit(string id, [Bind("Id,Nome,PaisId,LogoFile")] EstadoView estado) { if (id != estado.Id) { return(NotFound()); } if (ModelState.IsValid) { try { string urlLogo = _serviceUpload.Upload(estado.LogoFile); estado.FotoBandeira = urlLogo; await _httpClient.PutAsJsonAsync("estado", estado); return(RedirectToAction(nameof(Index))); } catch (DbUpdateConcurrencyException) { if (!await EstadoExists(estado.Id)) { return(NotFound()); } else { throw; } } } HttpResponseMessage response = await _httpClient.GetAsync("pais"); ViewData["PaisId"] = new SelectList(await response.Content.ReadAsAsync <List <PaisView> >(), "Id", "Nome", estado.PaisId); return(View(estado)); }
// GET: Estado/Edit/5 public async Task <IActionResult> Edit(string id) { if (id == null) { return(NotFound()); } HttpResponseMessage responseEstado = await _httpClient.GetAsync($"estado/{id}"); if (responseEstado.IsSuccessStatusCode) { EstadoView estado = await responseEstado.Content.ReadAsAsync <EstadoView>(); if (estado == null) { return(NotFound()); } HttpResponseMessage responsePais = await _httpClient.GetAsync("pais"); ViewData["PaisId"] = new SelectList(await responsePais.Content.ReadAsAsync <List <PaisView> >(), "Id", "Nome", estado.PaisId); return(View(estado)); } else { return(NotFound()); } }
public ActionResult ConfigurarCorreo() { try { EstadoRepository er = new EstadoRepository(); List <Estado> estados = er.Listar(); EstadoView ev = new EstadoView(); ev.Estados = estados; return(View("ConfigurarCorreo", ev)); } catch (Exception ex) { return(View("Mensaje", new HomeView { Mensaje = ex.Message })); } }
public async Task <IActionResult> Create([Bind("Id,Nome,PaisId,LogoFile")] EstadoView estado) { if (ModelState.IsValid) { string urlLogo = _serviceUpload.Upload(estado.LogoFile); estado.FotoBandeira = urlLogo; HttpResponseMessage result = await _httpClient.PostAsJsonAsync("estado", estado); if (result.IsSuccessStatusCode) { return(RedirectToAction(nameof(Index))); } } HttpResponseMessage response = await _httpClient.GetAsync("pais"); if (response.IsSuccessStatusCode) { ViewData["PaisId"] = new SelectList(await response.Content.ReadAsAsync <List <PaisView> >(), "Id", "Nome", estado.PaisId); } return(View(estado)); }
public ActionResult ConfigurarCorreo(string id) { try { Estado e = new Estado(); EstadoRepository er = new EstadoRepository(); List <Estado> estadosantes = er.Listar(); estadosantes.ForEach(p => { p.EnviarCorreo = false; p.Satisfactorio = false; p.Pendiente = false; }); foreach (string key in Request.Form.AllKeys) { string parte1 = key.Split(new char[] { '-' })[0]; e.Nombre = key.Split(new char[] { '-' })[1]; if (String.Compare(parte1, "Correo") == 0) { // Enviar Correo if (estadosantes.Exists(p => p.Nombre == e.Nombre)) { int indice = estadosantes.FindIndex(p => p.Nombre == e.Nombre); estadosantes[indice].EnviarCorreo = true; } } else if (String.Compare(parte1, "Satisfactorio") == 0) { // Estados Finales OK if (estadosantes.Exists(p => p.Nombre == e.Nombre)) { int indice = estadosantes.FindIndex(p => p.Nombre == e.Nombre); estadosantes[indice].Satisfactorio = true; } } else if (String.Compare(parte1, "Pendiente") == 0) { // Estados pendientes no anulados if (estadosantes.Exists(p => p.Nombre == e.Nombre)) { int indice = estadosantes.FindIndex(p => p.Nombre == e.Nombre); estadosantes[indice].Pendiente = true; } } } estadosantes.ForEach(p => { er.Actualizar(p); }); EstadoView ev = new EstadoView(); List <Estado> estados = er.Listar(); ev.Estados = estados; return(View("ConfigurarCorreo", ev)); } catch (Exception ex) { return(View("Mensaje", new HomeView { Mensaje = ex.Message })); } }