Esempio n. 1
0
        public bool updateBoat(Member member, int boatsToBeSkipped, Boat boatToAdd)
        {
            try
            {
                XElement xElement = XElement.Load(XMLFileInfo.Path);

                XElement memberToUpdate = (from Member in xElement.Elements(XMLFileInfo.Member)
                                               where (string)Member.Element(XMLFileInfo.ID) == member.MemberID.ToString()
                                               select Member).First();

                XElement boat = memberToUpdate.Elements(XMLFileInfo.Boat)
                    .Skip(boatsToBeSkipped)
                    .Take(1)
                    .First();

                boat.ReplaceWith(createBoat(boatToAdd));

                xElement.Save(XMLFileInfo.Path);

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
Esempio n. 2
0
        public bool add(Member member, Boat boat)
        {
            try
            {
                XDocument xElement = XDocument.Load(XMLFileInfo.Path);

                XElement particularMember = xElement.Element(XMLFileInfo.Members).Elements(XMLFileInfo.Member)
                                    .Where(a => a.Element(XMLFileInfo.ID).Value == member.MemberID.ToString())
                                    .Last();
                if (particularMember != null)
                    particularMember.Add(createBoat(boat));
                xElement.Save(XMLFileInfo.Path);

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
Esempio n. 3
0
        public List<Boat> getBoatsByMember(Member member)
        {
            List<Boat> boats = new List<Boat>();

            XElement xElement = XElement.Load(XMLFileInfo.Path);

            var memberInfo = from Member in xElement.Elements(XMLFileInfo.Member)
                             where (string)Member.Element(XMLFileInfo.ID) == member.MemberID.ToString()
                             select Member;

            XElement memberToGetBoatsFrom = memberInfo.First();

            foreach (XElement boat in memberToGetBoatsFrom.Elements(XMLFileInfo.Boat))
            {
                BoatType type = (BoatType)Enum.Parse(typeof(BoatType), boat.Attribute(XMLFileInfo.Type).Value);
                var boatToBeAdded = new Boat(type, int.Parse(boat.Value));
                boats.Add(boatToBeAdded);
            }

            boats.TrimExcess();

            return boats;
        }
Esempio n. 4
0
 private XElement createBoat(Boat boat)
 {
     return new XElement(XMLFileInfo.Boat, boat.Length, new XAttribute(XMLFileInfo.Type, boat.Type));
 }
Esempio n. 5
0
        public void editSelectedBoat(Boat b)
        {
            string editedBoatType = credentialBoatType();
            float edtiedBoatLength = credentialBoatLength(editedBoatType);

            _mc.editBoat(editedBoatType, edtiedBoatLength, b);
        }
Esempio n. 6
0
 public void deleteSelectedBoat(List<Boat> boats,Boat b)
 {
     _mc.deleteBoat(boats,b);
 }
Esempio n. 7
0
        public void editBoat(string boatType, float boatLength, Boat b)
        {
            b.BoatType = boatType;
            b.BoatLength = boatLength;

            saveChange();
        }
Esempio n. 8
0
        public void deleteBoat(List<Boat> boats, Boat b)
        {
            boats.Remove(b);

            saveChange();
        }