public void CrearVillain(Villain villain) { try { using (var context = new Context()) { context.Villains.Add(villain); context.SaveChanges(); } } catch (Exception) { throw; } }
public void BorrarVillain(int id) { try { using (var context = new Context()) { Villain villainD = context.Villains.Find(id); context.Villains.Remove(villainD); context.SaveChanges(); } } catch (Exception) { throw; } }
public void ActualizarVillain(int id, Villain villainModified) { try { using (var context = new Context()) { Villain villainD = context.Villains.Find(id); context.Villains.Remove(villainD); context.Villains.Add(villainModified); context.SaveChanges(); } } catch (Exception) { throw; } }
public Villain ObtenerVillain(int id) { Villain villainD = null; try { using (var context = new Context()) { villainD = context.Villains.Find(id); } } catch (Exception) { throw; } return(villainD); }
public Villain NombreAYAlMenos3Batallas() { Villain villain = null; try { using (var context = new Context()) { var villains = context.Villains.Any(x => x.Name[0].Equals("A") && x.NumberOfBatlles > 3); villain = villains.First(); } } catch (Exception) { throw; } return(villain); }