public override async Task LoadAsync() { try { if (IsBusy) { return; } IsBusy = true; if (Ligas.Count == 0) { var ligas = await _futebolApiService.GetLigasAsync(); if (ligas != null) { foreach (var liga in ligas) { Ligas.Add(liga); } } } } finally { IsBusy = false; } }
public void EliminarLiga(int id) { Ligas lig = this.GetLigaId(id); this.context.Ligas.Remove(lig); this.context.SaveChanges(); }
public async Task <IActionResult> Editar(int id, [Bind("Nombre")] Ligas ligas) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { Ligas entidad = _context.Ligas.Find(id); entidad.Nombre = ligas.Nombre.Trim(); _context.Ligas.Update(entidad); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException ex) { string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex); return(BadRequest(errMsg)); } catch (Exception ex) { string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex); return(BadRequest(errMsg)); } return(Ok(ligas)); }
public async Task <IActionResult> Crear([Bind("Nombre")] Ligas ligas) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { ligas.Nombre = ligas.Nombre.Trim(); _context.Ligas.Add(ligas); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException ex) { string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex); return(BadRequest(errMsg)); } catch (Exception ex) { string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex); return(BadRequest(errMsg)); } return(Ok("Registro Actualizado")); }
public async Task <IActionResult> Eliminar(int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { Ligas entidad = _context.Ligas.Find(id); _context.Ligas.Remove(entidad); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException ex) { string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex); return(BadRequest(errMsg)); } catch (Exception ex) { string errMsg = FormateadorCadenas.ObtenerMensajesErrores(ex); return(BadRequest(errMsg)); } return(Ok()); }
public void ModificarLiga(int id, String nombre, String descripcion) { Ligas lig = this.GetLigaId(id); lig.Nombre = nombre; lig.Descripcion = descripcion; this.context.SaveChanges(); }
public void NuevaLiga(String nombre, String descripcion) { Ligas lig = new Ligas(); lig.IdLiga = this.GetMaxIdLiga() + 1; lig.Nombre = nombre; lig.Descripcion = descripcion; this.context.Add(lig); this.context.SaveChanges(); }
public void ModificarLiga(Ligas lig) { this.repo.ModificarLiga(lig.IdLiga, lig.Nombre, lig.Descripcion); }
public void NuevaLiga(Ligas lig) { this.repo.NuevaLiga(lig.Nombre, lig.Descripcion); }