/// <summary> /// Retrives a specific roster using the repository. /// </summary> /// <param name="id"></param> /// <returns></returns> private FighterList GetRosterByID(int id) { FighterList tempRoster = null; FileIoStatus = FileIoMessage.None; try { using (TeamRosterRepository tRR = new TeamRosterRepository()) { tempRoster = tRR.GetByID(id); }; if (tempRoster != null) { FileIoStatus = FileIoMessage.Complete; } else { FileIoStatus = FileIoMessage.NoRecordsFound; } } catch (Exception) { FileIoStatus = FileIoMessage.FileAccessError; } return(tempRoster); }
/// <summary> /// Retrives all rosters through the repository. /// </summary> /// <param name="id"></param> /// <returns></returns> private List <FighterList> GetAllRosters() { List <FighterList> tempRoster = new List <FighterList>(); FileIoStatus = FileIoMessage.None; try { using (TeamRosterRepository tRR = new TeamRosterRepository()) { tempRoster = tRR.GetAll() as List <FighterList>; }; if (tempRoster != null) { FileIoStatus = FileIoMessage.Complete; } else { FileIoStatus = FileIoMessage.NoRecordsFound; } } catch (Exception) { FileIoStatus = FileIoMessage.FileAccessError; } return(tempRoster); }
/// <summary> /// Update an item in persistance. /// </summary> /// <param name="updateList"></param> public void UpdateRoster(FighterList updateList) { try { if (GetRosterByID(updateList.ListID) != null) { using (TeamRosterRepository tRR = new TeamRosterRepository()) { tRR.UpdateRoster(updateList); } FileIoStatus = FileIoMessage.Complete; MessageBoxResult notice = System.Windows.MessageBox.Show($"{FileIoStatus}", "Status", System.Windows.MessageBoxButton.OK); } else { FileIoStatus = FileIoMessage.RecordNotFound; MessageBoxResult notice = System.Windows.MessageBox.Show($"{FileIoStatus}", "Status", System.Windows.MessageBoxButton.OK); } } catch (Exception) { FileIoStatus = FileIoMessage.FileAccessError; MessageBoxResult notice = System.Windows.MessageBox.Show($"{FileIoStatus}", "Status", System.Windows.MessageBoxButton.OK); } }
/// <summary> /// Removes a roster from persistance. /// </summary> /// <param name="id"></param> public void DeleteRosterFromPersistance(int id) { try { if (GetRosterByID(id) != null) { using (TeamRosterRepository tRR = new TeamRosterRepository()) { tRR.DeleteRoster(id); } FileIoStatus = FileIoMessage.Complete; MessageBoxResult notice = System.Windows.MessageBox.Show($"{FileIoStatus}", "Status", System.Windows.MessageBoxButton.OK); } else { FileIoStatus = FileIoMessage.RecordNotFound; MessageBoxResult notice = System.Windows.MessageBox.Show($"{FileIoStatus}", "Status", System.Windows.MessageBoxButton.OK); } } catch (Exception) { FileIoStatus = FileIoMessage.FileAccessError; MessageBoxResult notice = System.Windows.MessageBox.Show($"{FileIoStatus}", "Status", System.Windows.MessageBoxButton.OK); } }
/// <summary> /// Method that adds a roster to persistance through the repository. /// </summary> /// <param name="fighterList"></param> public void AddRosterToPersistance(FighterList newRoster) { try { if (newRoster != null) { using (TeamRosterRepository tRR = new TeamRosterRepository()) { tRR.CreateRoster(newRoster); } FileIoStatus = FileIoMessage.Complete; MessageBoxResult notice = System.Windows.MessageBox.Show($"{FileIoStatus}", "Status", System.Windows.MessageBoxButton.OK); } } catch (Exception) { FileIoStatus = FileIoMessage.FileAccessError; MessageBoxResult notice = System.Windows.MessageBox.Show($"{FileIoStatus}", "Status", System.Windows.MessageBoxButton.OK); } }
public TeamRosterDomain(TeamRosterContext context) { _context = context; _repository = new TeamRosterRepository(_context); }