public bool AddStadium(Stadium stadium) { try { using (dbEntities1 context = new dbEntities1()) { context.Stadium.Add(stadium); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditClub(string newName, int newStadiumID, int newRecordID, long oldClubID) { try { using (dbEntities1 context = new dbEntities1()) { Club club = context.Club.FirstOrDefault(x => x.id == oldClubID); club.name = newName; club.stadiumID = newStadiumID; club.recordID = newRecordID; context.Entry(club).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditStadium(string newName, string newCity, string newCountry, long iD) { try { using (dbEntities1 context = new dbEntities1()) { Stadium stadium = context.Stadium.FirstOrDefault(x => x.id == iD); stadium.name = newName; stadium.city = newCity; stadium.country = newCountry; context.Entry(stadium).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public bool RemoveClub(int clubID) { try { using (dbEntities1 context = new dbEntities1()) { Club club = context.Club.FirstOrDefault(x => x.id == clubID); if (!CanRemoveClub(club))//nie posiada graczy ani członków sztabu { return(false); } context.Club.Remove(club); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public bool RemoveStadium(long stadiumID) { try { using (dbEntities1 context = new dbEntities1()) { Stadium stadium = context.Stadium.FirstOrDefault(x => x.id == stadiumID); if (!CanRemoveStadium(stadium))//nie posiada przypisanych klubów { return(false); } context.Stadium.Remove(stadium); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
//public void AddClub(string name, Stadium stadium) //{ // try // { // using (dbEntities1 context = new dbEntities1()) // { // Club club = new Club // { // name = name, // }; // if (stadium!=null) // { // club.Stadium = stadium; // } // context.Club.Add(club); // context.SaveChanges(); // } // } // catch (Exception e) // { // throw e; // } //} public void AddClub(string name, long stadiumID, long recordID) { try { using (dbEntities1 context = new dbEntities1()) { Stadium stadium = context.Stadium.FirstOrDefault(x => x.id == stadiumID); Record record = context.Record.FirstOrDefault(x => x.id == recordID); Club club = new Club { name = name, Stadium = stadium, Record = record }; context.Club.Add(club); context.SaveChanges(); } } catch (Exception e) { throw e; } }