public List <Category> GetAll() { try { using (var context = new AppContext()) { return(context.Categories.ToList()); } }catch (Exception ex) { Console.Write(ex); throw ex; } }
public Nationality GetById(int id) { Nationality nationality; try { using (var context = new AppContext()) { nationality = context.Nationality.SingleOrDefault(n => n.NationalityId == id); } } catch (Exception ex) { Console.WriteLine(ex); throw; } return(nationality); }
public List <Nationality> getAll() { List <Nationality> nationalities; try { using (var context = new AppContext()) { nationalities = context.Nationality.ToList(); } } catch (Exception ex) { Console.WriteLine(ex); throw; } return(nationalities); }
public bool Delete(int id) { Nationality dbNationality; try { using (var context = new AppContext()) { dbNationality = GetById(id); context.Nationality.Remove(dbNationality); context.SaveChanges(); return(true); } } catch (Exception ex) { Console.WriteLine(ex); throw ex; } }
public Nationality Add(Nationality nationality) { Nationality dbNationality; try { using (var context = new AppContext()) { dbNationality = context.Nationality.Add(nationality); context.SaveChanges(); } } catch (Exception ex) { Console.WriteLine(ex); throw; } return(dbNationality); }
public Nationality Update(Nationality nationality) { try { using (var context = new AppContext()) { if (nationality != null) { context.Nationality.Attach(nationality); context.Entry(nationality).State = EntityState.Modified; context.SaveChanges(); } } } catch (Exception ex) { Console.WriteLine(ex); throw; } return(nationality); }
public CategoryRepository(AppContext context) { _context = context; }
public NationalityRepository(AppContext context) { _context = context; }
public MatchRepository(AppContext context) { _context = context; }