Exemplo n.º 1
0
        ///// <summary>
        ///// To print out all the signed contract
        ///// </summary>
        //public void AllContractsSigned()
        //{
        //    var n = SignedContracts();
        //    foreach (Contract item in n)
        //        Console.WriteLine(item);
        //}


        /// <summary>
        /// Function to show the list of the nanny that the address corresponds to the request of the mother
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public List <Nanny> GoodDistance(MotherRequest m)
        {
            List <Nanny> l = new List <Nanny>();

            foreach (Nanny n in GetAllNanny())
            {
                //  if the mother asked for a specific address
                if (m.SearchAddress != "")
                {
                    //  if distance between mother's address and mother' search address
                    //  bigger than distance between mother's and nanny's address
                    //  OR
                    //  distance between mother's search address and nanny's address
                    //  lower than mother's accepted distance
                    if (Distance(m.Address, m.SearchAddress) > Distance(m.Address, n.Address) ||
                        Distance(m.SearchAddress, n.Address) <= m.DistanceAccepted)
                    {
                        l.Add(n);
                    }
                }

                else if (Distance(m.Address, n.Address) <= m.DistanceWanted)
                {
                    l.Add(n);
                }
            }

            return(l);
        }
Exemplo n.º 2
0
        MotherRequest ConvertMotherRequest(XElement element)
        {
            MotherRequest m = new MotherRequest();

            m.Address = (from x in element.Elements()
                         where x.Name == "Address"
                         select x.Value).FirstOrDefault();

            m.SearchAddress = (from x in element.Elements()
                               where x.Name == "SearchAddress"
                               select x.Value).FirstOrDefault();

            m.DistanceAccepted = (from x in element.Elements()
                                  where x.Name == "DistanceAccepted"
                                  select Convert.ToInt32(x.Value)).FirstOrDefault();

            m.DistanceWanted = (from x in element.Elements()
                                where x.Name == "DistanceWanted"
                                select Convert.ToInt32(x.Value)).FirstOrDefault();

            m.P = (from x in element.Elements()
                   where x.Name == "Planning"
                   select ConvertPlanning(x)).FirstOrDefault();

            return(m);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Return a list of nannies which satisfy the mother conditions
        /// </summary>
        /// <param name="R"></param>
        /// <returns></returns>
        public List <Nanny> PlanningAccordance(MotherRequest r)
        {
            //  the new list to return
            List <Nanny>             ln   = new List <Nanny>();
            List <CoupleMotherNanny> lcmn = new List <CoupleMotherNanny>();

            //  create a list of couple mother nanny and sort it
            foreach (Nanny n in GetAllNanny())
            {
                lcmn.Add(new CoupleMotherNanny(r, n));
            }
            lcmn.Sort();

            //  check existence of perfect nanny
            for (int i = 0; i < lcmn.Count; i++)
            {
                if (lcmn[i].AbsoluteConcordance)
                {
                    ln.Add(lcmn[i].N);
                }
            }

            if (ln.Count == 0) //if the list is empty
            {
                ln = NearNanny(lcmn);
            }

            return(ln);
        }
Exemplo n.º 4
0
 XElement ConvertMotherRequest(MotherRequest m)
 {
     return(new XElement("MotherRequest",
                         new XElement("Address", m.Address),
                         new XElement("SearchAddress", m.SearchAddress),
                         new XElement("IsSearchAddress", m.IsSearchAddress.ToString()),
                         new XElement("DistanceWanted", m.DistanceWanted),
                         new XElement("DistanceAccepted", m.DistanceAccepted),
                         new XElement(ConvertPlanning(m.P))));
 }