public void sendToBoatList(Boat boat) { Boatlist.Add(boat); }
//Returns all boats of the specific member public List<Boat> getMemberBoats(string personalNumber) { XDocument doc = XDocument.Load("..\\..\\Model\\storage.xml"); IEnumerable<XElement> elements = (from x in doc.Root.Elements() where x.Attribute("personal_id").Value == personalNumber select x); XElement xEle = elements.First(); IEnumerable<XElement> boats = (from x in xEle.Elements() select x); List<Boat> memberBoats = new List<Boat>(); if (boats.Any()) { foreach(XElement boatElement in boats){ string length = boatElement.Attribute("length").Value; string temp1 = boatElement.Attribute("type").Value; Boat.boats_type type = (Boat.boats_type)Enum.Parse(typeof(Boat.boats_type), temp1); String temp2 = boatElement.Attribute("boatID").Value; Guid boat_id = Guid.Parse(temp2); Boat boat = new Boat(boatElement.Attribute("name").Value, Int32.Parse(length), type, boat_id); memberBoats.Add(boat); } } return memberBoats; }
// argument Listan public void selectMember(IReadOnlyCollection<Member> list) { ConsoleView test = new ConsoleView(); // show menyn int choice = int.Parse(Console.ReadLine()); if(choice == 0) { return; } choice--; Member member = list.ElementAt(choice); test.ShowMembers(member); // skickar till show member visning av medlemmar int menuChoicce = int.Parse(Console.ReadLine()); switch (menuChoicce) // menualternativ för Medlemmen { case 0: return; case 1: member.GetName = test.Rename(); // change name break; case 2: MemberDAL.removeMember(choice); // tas bort medlemmen break; case 3: member.GetSecurityNumber = test.ChangeNumber(); // ändra personlighets nummer break; case 4: test.ViewBoattype(); int Boatchoice = int.Parse(test.Boattypeinfo()); // användning av inmatning av boatchoice double BoatLength = double.Parse(test.BoattypeLength()); //inmatning båtlängd // kan inte använda console write line eftersom det är void Boat FullBoat = new Boat(Boatchoice,BoatLength); // instans av ny objekt( med intagen längd av båtlängd och båtkategorier member.sendToBoatList(FullBoat); break; case 5: test.ShowBoat(member); selectBoat(member); break; default: break; } }
//Returns a boat of a specific member public Boat getBoat(string personalNumber, string boatName) { XDocument doc = XDocument.Load("..\\..\\Model\\storage.xml"); IEnumerable<XElement> elements = (from x in doc.Root.Elements() where x.Attribute("personal_id").Value == personalNumber select x); XElement xEle = elements.First(); IEnumerable<XElement> boats = (from x in xEle.Elements() where x.Attribute("name").Value == boatName select x); if (boats.Any()) { XElement boatElement = boats.First(); String length= boatElement.Attribute("length").Value; String type = boatElement.Attribute("type").Value; Boat.boats_type t = (Boat.boats_type)Enum.Parse(typeof(Boat.boats_type), type); Boat b = new Boat(boatElement.Attribute("name").Value, Int32.Parse(length), t); }else { throw new Exception("There is no boat for this member in the system"); } return null; }
public void AddBoat(Boat boat) { _boats.Add(boat); }