internal List <ReffereViewModel> GetAllReffere() { try { using (dbEntities1 context = new dbEntities1()) { List <Referee> reffereList = context.Referee.ToList(); List <ReffereViewModel> list = new List <ReffereViewModel>(); foreach (Referee item in reffereList) { list.Add(new ReffereViewModel { ID = item.id, FirstName = item.firstName, LastName = item.lastName, Salary = item.salary, RecordID = item.Record != null ? item.Record.id : 0 }); } return(list); } } catch (Exception e) { throw e; } }
internal List <TimetableViewModel> GetAllTimetable() { try { using (dbEntities1 context = new dbEntities1()) { List <Timetable> timetableList = context.Timetable.ToList(); List <TimetableViewModel> list = new List <TimetableViewModel>(); foreach (Timetable item in timetableList) { list.Add(new TimetableViewModel { ID = item.id, MatchID = item.Match.id, RefereeID = item.Referee.id }); } return(list); } } catch (Exception e) { throw e; } }
internal bool EditMatch(int stadiumID, int hostID, int guestID, int mainRefereeID, int technicalRefereeID, int linearRefereeID, int observerRefereeID, int hostGoals, int guestGoals, int currentMatchID) { try { using (dbEntities1 context = new dbEntities1()) { Match match = context.Match.FirstOrDefault(x => x.id == currentMatchID); match.stadiumID = stadiumID; match.hostID = hostID; match.guestID = guestID; match.mainRefereeID = mainRefereeID; match.technicalRefereeID = technicalRefereeID; match.linesRefereeID = linearRefereeID; match.observerRefereeID = observerRefereeID; match.hostGoals = hostGoals; match.guestGoals = guestGoals; context.Entry(match).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal List <MatchViewModel> GetAllMatches() { try { using (dbEntities1 context = new dbEntities1()) { List <Match> matchesList = context.Match.ToList(); List <MatchViewModel> list = new List <MatchViewModel>(); foreach (Match item in matchesList) { list.Add(new MatchViewModel { ID = item.id, Stadium_Name = item.Stadium.name, Host_Name = item.Club.name, Guest_Name = item.Club1.name, MainReffere = item.Referee.lastName, TechnicalReffere = item.Referee1.lastName, LinearReffere = item.Referee2.lastName, ObserverReffere = item.Referee3.lastName, HostGoals = item.hostGoals, GuestGoals = item.guestGoals }); } return(list); } } catch (Exception e) { throw e; } }
public void AddMatchByTagName(string stadiumName, string hostID, string guestID, string mainReffereID, string technicalReffereID, string linearReffereID, string observerReffereID, int hostGoals, int guestGoals) { try { using (dbEntities1 context = new dbEntities1()) { Stadium stadium = context.Stadium.FirstOrDefault(x => x.name == stadiumName); Club hostClub = context.Club.FirstOrDefault(x => x.name == hostID); Club guestClub = context.Club.FirstOrDefault(x => x.name == guestID); Referee mainReffere = context.Referee.FirstOrDefault(x => x.lastName == mainReffereID); Referee technicalReffere = context.Referee.FirstOrDefault(x => x.lastName == technicalReffereID); Referee linearReffere = context.Referee.FirstOrDefault(x => x.lastName == linearReffereID); Referee observerReffere = context.Referee.FirstOrDefault(x => x.lastName == observerReffereID); Match match = new Match { Stadium = stadium, Club = hostClub, Club1 = guestClub, Referee = mainReffere, Referee1 = technicalReffere, Referee2 = linearReffere, Referee3 = observerReffere, hostGoals = hostGoals, guestGoals = guestGoals }; context.Match.Add(match); context.SaveChanges(); } } catch (Exception e) { throw e; } }
internal bool AddWinners(int clubID, string year, int wonMatches, int lostMatches, int goalsScored, int goalsLost) { try { using (dbEntities1 context = new dbEntities1()) { Winners winners = new Winners { clubID = clubID, year = year, wonMatches = wonMatches, lostMatches = lostMatches, goalsScored = goalsScored, goalsLost = goalsLost }; context.Winners.Add(winners); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public List <TicketViewModel> GetAllTicket() { try { using (dbEntities1 context = new dbEntities1()) { List <Ticket> ticketList = context.Ticket.ToList(); List <TicketViewModel> list = new List <TicketViewModel>(); foreach (Ticket item in ticketList) { list.Add(new TicketViewModel { ID = item.id, PESEL = item.PESEL, MatchID = item.Match.id }); } return(list); } } catch (Exception e) { throw e; } }
public List <TicketViewModel> GetTicketByMatchIDVieWModel(long matchID) { try { using (dbEntities1 context = new dbEntities1()) { List <Ticket> ticketList = context.Ticket.Where(x => x.matchID == matchID).ToList(); List <TicketViewModel> list = new List <TicketViewModel>(); foreach (Ticket item in ticketList) { list.Add(new TicketViewModel { ID = item.id, PESEL = item.PESEL }); } return(list); } } catch (Exception e) { throw e; } }
internal List <WinnersViewModel> GetAllWinners() { try { using (dbEntities1 context = new dbEntities1()) { List <Winners> winnersList = context.Winners.ToList(); List <WinnersViewModel> list = new List <WinnersViewModel>(); foreach (Winners item in winnersList) { list.Add(new WinnersViewModel { ID = item.id, year = item.year, clubID = item.Club.id, wonMatches = item.wonMatches, lostMatches = item.lostMatches, goalsScored = item.goalsScored, goalsLost = item.goalsLost }); } return(list); } } catch (Exception e) { throw e; } }
internal List <TrainingStaffViewModel> GetAllStaff() { try { using (dbEntities1 context = new dbEntities1()) { List <TrainingStaff> trainingStaffList = context.TrainingStaff.ToList(); List <TrainingStaffViewModel> list = new List <TrainingStaffViewModel>(); foreach (TrainingStaff item in trainingStaffList) { list.Add(new TrainingStaffViewModel { ID = item.id, FirstName = item.firstName, LastName = item.lastName, ClubName = item.Club.name, age = item.age, duty = item.duty }); } return(list); } } catch (Exception e) { throw e; } }
internal List <PlayerViewModel> GetAllPlayer() { try { using (dbEntities1 context = new dbEntities1()) { List <Player> playerList = context.Player.ToList(); List <PlayerViewModel> list = new List <PlayerViewModel>(); foreach (Player item in playerList) { list.Add(new PlayerViewModel { ID = item.id, FirstName = item.firstName, LastName = item.lastName, ClubName = item.Club.name, RecordID = item.Record != null ? item.Record.id : 0 }); } return(list); } } catch (Exception e) { throw e; } }
public List <Ticket> GetTicketByMatchID(long matchID) { try { using (dbEntities1 context = new dbEntities1()) { List <Ticket> ticketList = context.Ticket.Where(x => x.matchID == matchID).ToList(); return(ticketList); } } catch (Exception e) { throw e; } }
internal List <Record> GetAllRecord() { try { using (dbEntities1 context = new dbEntities1()) { List <Record> record = context.Record.ToList(); return(record); } } catch (Exception e) { throw e; } }
public bool AddRecord(Record record) { try { using (dbEntities1 context = new dbEntities1()) { context.Record.Add(record); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditRecord(string newType, string newName, long currentRecordID) { try { using (dbEntities1 context = new dbEntities1()) { Record record = context.Record.FirstOrDefault(x => x.id == currentRecordID); record.type = newType; record.name = newName; context.Entry(record).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditTicket(int matchID, string pESEL, long currentTicketID) { try { using (dbEntities1 context = new dbEntities1()) { Ticket ticket = context.Ticket.FirstOrDefault(x => x.id == currentTicketID); ticket.matchID = matchID; ticket.PESEL = pESEL; context.Entry(ticket).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditTimetable(int matchID, int refereeID, long currentTimetableID) { try { using (dbEntities1 context = new dbEntities1()) { Timetable timetable = context.Timetable.FirstOrDefault(x => x.id == currentTimetableID); timetable.matchID = matchID; timetable.refereeID = refereeID; context.Entry(timetable).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public bool RemoveTicketByMatchID(long matchID) { try { using (dbEntities1 context = new dbEntities1()) { List <Ticket> ticketList = context.Ticket.Where(x => x.matchID == matchID).ToList(); foreach (Ticket item in ticketList) { context.Ticket.Remove(item); } context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool RemoveStaff(int iD) { try { using (dbEntities1 context = new dbEntities1()) { TrainingStaff staff = context.TrainingStaff.FirstOrDefault(x => x.id == iD); if (!CanRemoveStaff(staff)) { return(false); } context.TrainingStaff.Remove(staff); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public bool RemoveTicket(long ticketID) { try { using (dbEntities1 context = new dbEntities1()) { Ticket ticket = context.Ticket.FirstOrDefault(x => x.id == ticketID); if (!CanRemoveTicket(ticket)) { return(false); } context.Ticket.Remove(ticket); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditReferee(string firstName, string lastName, double salary, int recordID, int iD) { try { using (dbEntities1 context = new dbEntities1()) { Referee referee = context.Referee.FirstOrDefault(x => x.id == iD); referee.firstName = firstName; referee.lastName = lastName; referee.salary = salary; referee.recordID = recordID; context.Entry(referee).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public bool RemoveReffere(long reffereID) { try { using (dbEntities1 context = new dbEntities1()) { Referee referee = context.Referee.FirstOrDefault(x => x.id == reffereID); if (!CanRemoveReffere(referee)) { return(false); } context.Referee.Remove(referee); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public bool RemoveTimetable(long ID) { try { using (dbEntities1 context = new dbEntities1()) { Timetable timetable = context.Timetable.FirstOrDefault(x => x.id == ID); if (!CanRemoveTimetable(timetable)) { return(false); } context.Timetable.Remove(timetable); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool RemovePlayer(int iD) { try { using (dbEntities1 context = new dbEntities1()) { Player player = context.Player.FirstOrDefault(x => x.id == iD); if (!CanRemovePlayer(player)) { return(false); } context.Player.Remove(player); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool RemoveWinners(int iD) { try { using (dbEntities1 context = new dbEntities1()) { Winners winners = context.Winners.FirstOrDefault(x => x.id == iD); if (!CanRemoveWinners(winners)) { return(false); } context.Winners.Remove(winners); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
internal bool EditPlayer(string firstName, string lastName, int clubID, int recordID, int playerID) { try { using (dbEntities1 context = new dbEntities1()) { Player player = context.Player.FirstOrDefault(x => x.id == playerID); player.firstName = firstName; player.lastName = lastName; player.clubID = clubID; player.recordID = recordID; context.Entry(player).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public void AddReffere(string firstName, string lastName, double salary, int recordID) { try { using (dbEntities1 context = new dbEntities1()) { Referee referee = new Referee { firstName = firstName, lastName = lastName, salary = salary, recordID = recordID }; context.Referee.Add(referee); context.SaveChanges(); } } catch (Exception e) { throw e; } }
internal bool EditStaff(string firstName, string lastName, int clubID, int staffID, int age, string duty) { try { using (dbEntities1 context = new dbEntities1()) { TrainingStaff staff = context.TrainingStaff.FirstOrDefault(x => x.id == staffID); staff.firstName = firstName; staff.lastName = lastName; staff.clubID = clubID; staff.age = age; staff.duty = duty; context.Entry(staff).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public bool RemoveMatch(long matchID) { try { using (dbEntities1 context = new dbEntities1()) { Match match = context.Match.FirstOrDefault(x => x.id == matchID); if (!CanRemoveMatch(match))//nie posiada graczy ani członków sztabu { return(false); } ticketService.RemoveTicketByMatchID(match.id); context.Match.Remove(match); context.SaveChanges(); return(true); } } catch (Exception e) { throw e; } }
public void AddTimetable(long matchID, long refereeID) { try { using (dbEntities1 context = new dbEntities1()) { Match match = context.Match.FirstOrDefault(x => x.id == matchID); Referee referee = context.Referee.FirstOrDefault(x => x.id == refereeID); Timetable timetable = new Timetable { Match = match, Referee = referee }; context.Timetable.Add(timetable); context.SaveChanges(); } } catch (Exception e) { throw e; } }