public void CreateMember(MemberList members, string Name, int SocialNr) { int MemberId = SetMemberId(members); Member currentMember = new Member(); currentMember.MemberId = MemberId; currentMember.Name = Name; currentMember.SocialNr = SocialNr; members.Add(currentMember); }
public Member GetMember() { var member = new Member(); Console.Write("Förnamn: "); member.FirstName = Console.ReadLine(); Console.Write("Last name: "); member.LastName = Console.ReadLine(); Console.Write("Social Security Number: "); member.SocialSecurityNumber = Console.ReadLine(); return member; }
public void DisplayMember(Member member) { Console.WriteLine(String.Format("Name: {0} {1}", member.FirstName, member.LastName)); Console.WriteLine(String.Format("Social security number: {0}", member.SocialSecurityNumber)); Console.WriteLine(String.Format("Member ID: {0}", member.MemberID)); Console.WriteLine("BOATS: "); foreach (var boat in member.Boats) { Console.WriteLine("Type: {0}. Length: {1}", boat.Type.ToString(), boat.Length.ToString()); } }
public int GetIndexOfBoat(Member member) { Console.Clear(); foreach (var boat in member.Boats) { Console.WriteLine(String.Format("{0}, {1}, {2}", member.Boats.IndexOf(boat) + 1, boat.Type, boat.Length)); } Console.Write("Please enter ID of boat: "); int index = GetIntInputFromString(); return index - 1; }
public void UpDateBoat(MemberList members) { Boat currentBoat = new Boat(); Member currentMember = new Member(); Console.WriteLine("Skriv in det medlemsnummer som du vill redigera en båt på."); currentMember = currentMember.ObjectFinder1(members); Console.WriteLine("Skriv in nummret på den båt du vill ändra på:"); currentBoat.UpDateBoat(currentMember, currentBoat); Console.WriteLine("\nDu har redigerat en båt."); ContinueOnKeyPressed(); }
//Adds a boat to the specific member by first choosing the boat type, //then the lenght of the boat public void addBoatToMember(Member member) { Console.Clear(); main_menu.boatTypeHeader(); listOfBoatTypes(); Boat.BoatType boatType = Boat.BoatType.Other; ConsoleKeyInfo input = Console.ReadKey(); switch (input.Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: boatType = Boat.BoatType.Salilboat; break; case ConsoleKey.D2: case ConsoleKey.NumPad2: boatType = Boat.BoatType.Motorsailer; break; case ConsoleKey.D3: case ConsoleKey.NumPad3: boatType = Boat.BoatType.Kayak_Canoe; break; case ConsoleKey.D4: case ConsoleKey.NumPad4: boatType = Boat.BoatType.Other; break; //Back to Main Menu default: run(); break; } main_menu.showBoatLengthMenu(boatType); try { int boatLength = int.Parse(Console.ReadLine()); member.addBoat(new Boat(boatType, boatLength)); member_dal.saveMember(); listOfMembers.Clear(); run(); } catch (Exception) { run(); } }
public void UpDateMember(MemberList members) { Member currentMember = new Member(); Console.WriteLine("Skriv in det medlemsnummer som du vill redigera uppgifter på:"); var member = new Member(); currentMember = member.ObjectFinder1(members); Console.WriteLine("Skriv in nummret på det fält du vill ändra på:"); Console.WriteLine("1: {0}", currentMember.Name); Console.WriteLine("2: {0}", currentMember.SocialNr); member.UpDateMember(currentMember); Console.WriteLine("\nDu har updaterat en medlem."); ContinueOnKeyPressed(); }
public void ShowMember(MemberList members) { Console.WriteLine("Skriv in det medlemsnummer som du vill titta på:"); var member = new Member(); Member currentMember = member.ShowMember(members); Console.WriteLine("\nNamn: {0}", currentMember.Name); Console.WriteLine("MedlemsNr: {0}", currentMember.MemberId); Console.WriteLine("PersonNr: {0}", currentMember.SocialNr); var boatView = new BoatView(); boatView.ShowBoats(currentMember); ContinueOnKeyPressed(); }
public void AddBoat(MemberList members) { Boat myBoat = new Boat(); Member currentMember = new Member(); var boatview = new BoatView(); currentMember = currentMember.ObjectFinder1(members); if (currentMember.BoatList == null) { currentMember.BoatList = new BoatList(); } int index = members.Members.IndexOf(currentMember); boatview.ShowBoatTypeAndLength(); AddBoatTypeAndLength(myBoat); currentMember.BoatList.Add(myBoat); members.Members.RemoveAt(index); members.Members.Insert(index, currentMember); }
public void ShowBoats(Member mObject) { var consoleView = new ConsoleView(); int counter = 1; try { if (mObject.BoatList.Boats == null) { } foreach (Boat bObject in mObject.BoatList.Boats) { Console.WriteLine("-------{0}--------", counter); Console.WriteLine(bObject.BoatType); Console.WriteLine("{0}m", bObject.BoatLength); counter++; } } catch (Exception) { Console.WriteLine("\nDet finns ingen båt på denna medlem."); ContinueOnKeyPressed(); consoleView.GetMenuChoice(); } }
public void CreateMember(MemberList members) { string Name; int SocialNr; while (true) { try { Console.WriteLine("Skriv in ditt namn: "); Name = Console.ReadLine(); break; } catch { Console.WriteLine("Fel inmatning! Försök igen"); } } while (true) { try { Console.WriteLine("Skriv in ditt personummer: "); SocialNr = int.Parse(Console.ReadLine()); break; } catch (Exception) { Console.WriteLine("Fel inmatning! Försök igen"); } } var member = new Member(); member.CreateMember(members, Name, SocialNr); Console.WriteLine("\nDu har lagt in en medlem."); ContinueOnKeyPressed(); }
private void UpdateMember(Member member, int key) { switch (key) { case 1: member.FirstName = _view.GetFirstName(); break; case 2: member.LastName = _view.GetLastName(); break; case 3: member.SocialSecurityNumber = _view.GetSocialSecurityNumber(); break; } }
//Shows the menu of what to change on the member public void updateMember(Member member) { Console.Clear(); main_menu.showUpdateMemberMenu(); ConsoleKeyInfo input = Console.ReadKey(); switch (input.Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: Console.Clear(); main_menu.showChangeMemberName(); member_dal.updateMemberName(member); listOfMembers.Clear(); run(); break; case ConsoleKey.D2: case ConsoleKey.NumPad2: Console.Clear(); main_menu.showChangeSnn(); member_dal.updateSnn(member); listOfMembers.Clear(); run(); break; //Back to Main Menu default: run(); break; } }
//Gets the member boats and let the user choose what boat to update public void updateBoat(Member member) { Console.Clear(); memberBoats(member); try { int id = int.Parse(Console.ReadLine()); updateBoatMenu(member.Boats.ElementAt(id)); } catch (Exception) { run(); } }
//Shows a menu for the selected member public void selectedMemberMenu(Member member) { main_menu.displaySelectedMemberMenu(); ConsoleKeyInfo input = Console.ReadKey(); switch (input.Key) { // Delete member case ConsoleKey.D1: case ConsoleKey.NumPad1: member_dal.removeMember(member); listOfMembers.Remove(member); member_dal.saveMember(); listOfMembers.Clear(); run(); break; //Update member case ConsoleKey.D2: case ConsoleKey.NumPad2: updateMember(member); break; //Add boat to member case ConsoleKey.D3: case ConsoleKey.NumPad3: addBoatToMember(member); break; //Remove boat case ConsoleKey.D4: case ConsoleKey.NumPad4: removeBoat(member); break; case ConsoleKey.D5: case ConsoleKey.NumPad5: updateBoat(member); break; //Back to Main Menu default: run(); break; } }
public void Add(Member obj) { _members.Add(obj); }
public void RemoveMember(MemberList members) { Member currentObject = new Member(); currentObject = ObjectFinder1(members); members.Members.Remove(currentObject); }
//Hämtar ett objekt public Member ObjectFinder1(MemberList members) { Member member = new Member(); while (true) { try { int IDtoFind = Convert.ToInt32(Console.ReadLine()); member = members.Members.Find(x => x.MemberId == IDtoFind); if (member == null) { Console.WriteLine("\nHittade inte medlemen, försök igen."); } else { return member; } } catch (Exception) { Console.WriteLine("Fel vid inmatning, försök igen."); } } }
public void RemoveMember(MemberList members) { Console.WriteLine("Skriv in det medlemsnummer som ska raderas:"); var member = new Member(); member.RemoveMember(members); Console.WriteLine("\nDu har raderat en medlem."); ContinueOnKeyPressed(); }
public void RemoveBoat(MemberList members) { Member currrentMember = new Member(); while (true) { try { currrentMember = currrentMember.ObjectFinder1(members); int counter = 1; Console.WriteLine("Välj nummer på den båt som ska raderas:"); foreach (Boat bObj in currrentMember.BoatList.Boats) { Console.WriteLine("{0}: {1} med längd {2}m", counter, bObj.BoatType, bObj.BoatLength); counter++; } int choice = Convert.ToInt32(Console.ReadLine()); choice--; currrentMember.BoatList.Boats.RemoveAt(choice); break; } catch (Exception) { Console.WriteLine("Ange ett giltigt nummer."); } } }
public int CountBoats(Member member) { int countBoat = 0; if (member.BoatList == null) { countBoat = 0; } else { countBoat = member.BoatList.Boats.Count(); } return countBoat; }
public void UpDateBoat(Member currentMember, Boat currentBoat) { var boatview = new BoatView(); boatview.ShowBoats(currentMember); int choise = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Du har valt att ändra på båt nr {0}", choise); int boatIndex = choise - 1; boatview.ShowBoatTypeAndLength(); AddBoatTypeAndLength(currentBoat); currentMember.BoatList.Add(currentBoat); currentMember.BoatList.Boats.RemoveAt(boatIndex); }
public void UpDateMember(Member currentMember) { int choise; while (true) { choise = Convert.ToInt32(Console.ReadLine()); if (choise == 1 || choise == 2) { if (choise == 1) { Console.WriteLine("Ändra {0} till: ", currentMember.Name); currentMember.Name = Console.ReadLine(); } if (choise == 2) { Console.WriteLine("Ändra {0} till: ", currentMember.SocialNr); while (true) { try { currentMember.SocialNr = int.Parse(Console.ReadLine()); break; } catch { Console.WriteLine("Fel inmatning, försök igen"); } } } break; } else { Console.WriteLine("Fel inmatning, försök igen."); } } }
//Shows the boats that the specific member owns public void memberBoats(Member member) { int id = 0; foreach (var boat in member.Boats) { main_menu.showMemberBoats(id, boat.BoatTypeProp, boat.BoatLenght); id++; } }
public void removeBoat(Member member) { Console.Clear(); main_menu.deleteBoatHeader(); memberBoats(member); main_menu.backToMember(); try { int id = int.Parse(Console.ReadLine()); member.deleteBoat(id); member_dal.saveMember(); listOfMembers.Clear(); run(); } catch (Exception) { run(); } }
public void run() { Console.Clear(); main_menu.show(); Random r = new Random(); ConsoleKeyInfo input = Console.ReadKey(); switch (input.Key) { //Pressed 1: Create new Member case ConsoleKey.D1: case ConsoleKey.NumPad1: main_menu.getName(); string name = Console.ReadLine(); main_menu.getSnn(); string snn = Console.ReadLine(); int randomNumber = 0; do { randomNumber = r.Next(int.MaxValue); } while (isSameUnique(randomNumber)); try { Member member = new Member(name, snn, randomNumber); member_dal.getMembers(); member_dal.addData(member); member_dal.saveMember(); run(); } catch (Exception) { run(); } break; //Pressed 2: Show compact list of all Members case ConsoleKey.D2: case ConsoleKey.NumPad2: Console.Clear(); member_dal.getMembers(); membersFromFile(); int i = 0; foreach (var m in member_dal.getMemberList()) { main_menu.showMembers(i, m.Name, m.Ssn, m.Boats.Count); i++; } main_menu.SelectUser(); int selectedUser = 0; try { selectedUser = int.Parse(Console.ReadLine()); showSelectedUser(selectedUser); } catch (Exception) { run(); } Console.ReadLine(); break; // KeyPress 3: Show detailed list of members case ConsoleKey.D3: case ConsoleKey.NumPad3: Console.Clear(); member_dal.getMembers(); membersFromFile(); foreach (var m in member_dal.getMemberList()) { main_menu.showSelectedUser(m.Name, m.Ssn, m.UniqueInt); memberBoats(m); } main_menu.backToMember(); Console.ReadLine(); run(); break; //Exits the program default: Environment.Exit(0); break; } }
public void AddData(Member member) { memberList.Add(member); }
public void SaveMember(Member member) { _members.Add(member); }