Пример #1
0
        public void MainMenu()
        {
            View.ConsoleView c = new View.ConsoleView();
            do
            {
                try
                {
                c.DisplayInfo();
                int Choice;
                string choices = System.Console.ReadLine();

                    Choice = int.Parse(choices);

                    switch (Choice)
                    {
                        case 0:
                            MemberDAL.SaveToFile();
                            return;

                        case 1:
                            Console.Clear();
                            member = new Member(c.OnRegister(), int.Parse(c.OnRegister()), int.Parse(c.OnRegister()));
                            break;

                        case 2:
                            EditMenu(c);
                            break;

                        case 3:

                            c.CompactList(MemberDAL.getMemberList());

                            break;

                        case 4:
                            c.VerboseList(MemberDAL.getMemberList());

                            break;
                    }

                }

                catch (Exception e)
                {
                    Console.WriteLine("nåt gick fel");

                }

            }
            while (Console.ReadKey(true).Key != ConsoleKey.Escape);
        }
Пример #2
0
 public void sendToMemberList(Member member)
 {
     MemberDAL.AddMemberToList(member);
 }
Пример #3
0
        //Returns a member from xaml file
        public Member getMember(String personalNumber)
        {
            XDocument doc = XDocument.Load("..\\..\\Model\\storage.xml");
            IEnumerable<XElement> members = (from x in doc.Root.Elements()
                                              where x.Attribute("personal_id").Value == personalNumber
                                              select x);
            if (members.Any())
            {
                XElement xEle = members.First();
                Member m = new Member();

                m.Personal_id = xEle.Attribute("personal_id").Value;
                m.Last_name = xEle.Attribute("last_name").Value;
                m.First_name = xEle.Attribute("first_name").Value;

                String temp = xEle.Attribute("member_id").Value;
                m.Member_id = Guid.Parse(temp);

                return m;
            }
            else {
                throw new Exception("Member does not exist."); }
        }
Пример #4
0
        //Returns a list of all the members in the xaml file
        public List<Member> getAllMembers()
        {
            XDocument doc = XDocument.Load("..\\..\\Model\\storage.xml");
            IEnumerable<XElement> elements = (from x in doc.Root.Elements()
                                              select x);

            List<Member> allMembers = new List<Member>();

            foreach(XElement e in elements){
                Member m = new Member();

                m.Personal_id = e.Attribute("personal_id").Value;
                m.Last_name = e.Attribute("last_name").Value;
                m.First_name = e.Attribute("first_name").Value;

                String temp = e.Attribute("member_id").Value;
                Guid guid = Guid.Parse(temp);
                m.Member_id = guid;

                allMembers.Add(m);
            }
            return allMembers;
        }
Пример #5
0
        public void selectBoat(Member member)
        {
            Boat boaten;
            IReadOnlyCollection<Member> newlist = MemberDAL.getMemberList(); ;
            ConsoleView test2 = new ConsoleView();
            //test2.bild();
            int choices = int.Parse(Console.ReadLine());
            if (choices == 0)
            {
                return;
            }
            choices--;

            test2.boatChoices();
            int boatchoice = int.Parse(Console.ReadLine());
            boaten = member.BoatList.ElementAt(choices);
            switch(boatchoice)
            {
                case 1:
                    member.RemoveBoatList(choices);
                    break;

                case 2:
                    test2.ViewBoattype();
                    choices = int.Parse(Console.ReadLine());
                test2.Boatchanges();
                    double newLength = double.Parse(Console.ReadLine());
                    //Boat FullBoat = new Boat(choices, newLength);
                    boaten.GetLength = newLength;                                  // egenskap == nya värdet
                    boaten.GetCategory = (Model.Boat.BoatCategory)choices;    // kan inte skicka in i egenskaper eftersom de inte har parameteer
                                                                          // hämtade objektet från båten
                                                                              // ändra värden via parse
                    break;

            }
        }
Пример #6
0
        public string OnBoatRegister(Member member)
        {
            System.Console.Clear();
            System.Console.WriteLine("======================================================");
            System.Console.WriteLine("            sparade info?                                 ");
            System.Console.WriteLine("");
            System.Console.WriteLine("======================================================");

            System.Console.WriteLine("Name: {0}, {1}, {2} {3}", member.GetName, member.GetMemberID,member.GetSecurityNumber);

            return System.Console.ReadLine();
        }
Пример #7
0
 //public int i { get; set; }
 internal void ShowMember(Member chosenMember)
 {
     throw new NotImplementedException();
 }
Пример #8
0
        public void ShowMembers(Member member)
        {
            System.Console.Clear();
            System.Console.WriteLine("======================================================");
            System.Console.WriteLine("             Selection Screen                                   ");
            System.Console.WriteLine("");
            System.Console.WriteLine("======================================================");

            System.Console.WriteLine("Name: {0}, {1}, {2}", member.GetName, member.GetSecurityNumber, member.GetMemberID);
            System.Console.WriteLine("--------------------------------------------------------------------------------");
            System.Console.WriteLine("Option to choose:\n 1-Rename name\n 2- Delete member \n 3- Change SecurityNumber \n 4- Add Boat \n 5- View the boat \n 0- Exit");

                  //return int.Parse(System.Console.ReadLine());
        }
Пример #9
0
 public void ShowBoat(Member member)
 {
     int i = 1;
     Console.WriteLine("Detaljer");
     foreach (Boat boat in member.BoatList)
     {
         System.Console.WriteLine("båt kategori : {0}   båtlängd :{1}   ID : {2}", boat.GetCategory, boat.GetLength, i++);
     }
     System.Console.Write("Chooice one boat ID to remove or update   :");
 }
Пример #10
0
        public void selectBoat(Member member)
        {
            Boat boaten;
            IReadOnlyCollection<Member> newlist = MemberDAL.getMemberList(); ;
            ConsoleView newview = new ConsoleView();
            //test2.bild();
            int choices = int.Parse(Console.ReadLine());
            if (choices == 0)
            {
                return;
            }
            choices--;

            newview.boatChoices();
            int boatchoice = int.Parse(Console.ReadLine());
            boaten = member.BoatList.ElementAt(choices);
            switch (boatchoice)
            {
                case 1:
                    member.RemoveBoatList(choices);
                    break;

                case 2:
                    newview.ViewBoattype();
                    choices = int.Parse(Console.ReadLine());
                    newview.Boatchanges();
                    double newLength = double.Parse(Console.ReadLine());

                    boaten.GetLength = newLength;
                    boaten.GetCategory = (Model.Boat.BoatCategory)choices;

                    break;

            }
        }