Esempio n. 1
0
        /* contract functions */

        /// <summary>
        /// add contract to contract's DB
        /// </summary>
        /// <param name="contract">the contract to add to ContractList</param>
        /// <remarks>
        /// accept contract, give the contract a number and add to contract list
        /// check that - nanny, mother and child exsist
        /// check also that there this contract dosn't already exsist
        /// throw exceptions accordingly
        /// </remarks>
        public void AddContract(Contract contract)
        {
            Nanny  nanny  = FindNanny(contract.NannyID);
            Mother mother = FindMother(contract.MotherID);
            Child  child  = FindChild(contract.ChildID);

            if (nanny != null)
            {
                if (mother != null)
                {
                    if (child != null)
                    {
                        if (FindContract(contract.ContractNumber) == null)
                        {
                            // if the contract number equals 0, give a new contract number
                            // if contract number is not 0 - means this is an update contract,
                            // don't give a new contract number
                            if (contract.ContractNumber == null)
                            {
                                contract.ContractNumber = ContractNumber++;
                            }
                            contract.IsContractSigned = true;
                            ContractList().Add(contract.Clone());
                        }
                        else
                        {
                            throw new DALException(child.FirstName + " dosn't exsist", "Add contract");
                        }
                    }
                    else
                    {
                        throw new DALException("this contract number already exsist", "Add contract");
                    }
                }
                else
                {
                    throw new DALException(mother.FullName() + " dosn't exsist", "Add contract");
                }
            }
            else
            {
                throw new DALException(nanny.FullName() + " dosn't exsist", "Add contract");
            }
        }
Esempio n. 2
0
        public void Valid(Nanny nanny)
        {
            string message = null;

            if (!nanny.ID.HasValue)
            {
                message += "Must fill the field ID\n";
            }
            if (string.IsNullOrEmpty(nanny.FirstName))
            {
                message += "Must fill the field First name\n";
            }
            if (string.IsNullOrEmpty(nanny.LastName))
            {
                message += "Must fill the field Last nam\n";
            }
            if (string.IsNullOrEmpty(nanny.Address))
            {
                message += "Must fill the field Adsress\n";
            }
            if (nanny.BirthDate > DateTime.Now)
            {
                message += "Invalid date\n";
            }
            if (!nanny.PhoneNumber.HasValue)
            {
                message += "Must fill the field PhoneNumber\n";
            }
            if (nanny.MaxAge < nanny.MinAge)
            {
                message += "The maximum age can not be greater than the minimum age\n";
            }
            for (int i = 0; i < 6; i++)
            {
                if (nanny.WorkHours[0][i] > nanny.WorkHours[1][i])
                {
                    message += "Late start time from end time at day " + ((days)i).ToString() + "\n";
                }
            }
            if (message != null)
            {
                throw new BLException(message, "AddNanny");
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Checks the compatibility between the nanny and the mother needs
 ///
 /// return true if the nnany compatiabil in the time of work
 /// return false if thay not compatiabil in the time of work
 /// </summary>
 /// <param name="nan">Nanny object to comper</param>
 /// <param name="mam">Mother object to comper</param>
 /// <returns></returns>
 public bool checkCompatibilityMotherNanny(Nanny nan, Mother mam)
 {
     for (int i = 0; i < 6; ++i)
     {   //Full day no compatibility
         if (mam.timeWorkofWeek[i].IsWork == true && nan.timeWorkofWeek[i].IsWork == false)
         {
             return(false);
         }
         else if (mam.timeWorkofWeek[i].IsWork == true && nan.timeWorkofWeek[i].IsWork == true)
         {//There is no compatibility during work hours
             if (mam.timeWorkofWeek[i].StartTime <nan.timeWorkofWeek[i].StartTime ||
                                                  mam.timeWorkofWeek[i].EndTime> nan.timeWorkofWeek[i].EndTime)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Esempio n. 4
0
        /// <summary>
        /// adds a nanny to archive of nanny's
        /// </summary>
        /// <param name="nanny"></param>
        public void addNanny(Nanny nanny)
        {
            // if this id number is already used
            if (IdExist(nanny.id))
            {
                throw new Exception("Sorry, but this ID number is already in the system.");
            }


            // if nanny is not over the age of 18 she cannot work
            if (DateTime.Now.CompareTo(nanny.birthday.AddYears(18)) >= 0)
            {
                myDal.addNanny(nanny);
            }
            else
            {
                throw new Exception("Joining the system is prohibited under the age of 18");
            }
        }
Esempio n. 5
0
        /// <summary>
        /// update nanny on the file
        /// </summary>
        /// <param name="nanny">the nanny to update</param>
        public void UpdateNanny(Nanny nanny)
        {
            List <Nanny> list = LoadFromXML <List <Nanny> >(nannyPath);
            bool         flag = true;

            foreach (Nanny item in list)
            {
                if (item.Id == nanny.Id)
                {
                    flag = false;
                }
            }
            if (flag)
            {
                throw new Exception("this nanny is not exist");
            }
            RemoveNanny(nanny.Id);
            AddNanny(nanny);
        }
Esempio n. 6
0
        public void AddNanny(Nanny n)
        {
            //logical actions
            if ((DateTime.Now.Year - n.Birthday.Year) < 18)//checks if the nanny not too young
            {
                throw new Exception("The nanny is too young");
            }
            //call DAL for action
            Idal mydal = FactoryDal.getDal();

            try
            {
                mydal.AddNanny(n);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 7
0
        private void nannyUpDataComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.nannyUpDataComboBox.SelectedItem is Nanny)
            {
                this.userWorkHours.Clear();

                this.nannyToUpdate = ((Nanny)this.nannyUpDataComboBox.SelectedItem).
                                     DeepClone <Nanny>((Nanny)this.nannyUpDataComboBox.SelectedItem);
                this.DataContext = nannyToUpdate;

                if (this.nannyToUpdate._YearsOfExperience >= 5)                                       ////////
                {
                    this.nannyToUpdate.NumOfStars = 3;                                                /////////////////
                }
                if (this.nannyToUpdate.NumOfStars == 3 && this.nannyToUpdate._YearsOfExperience >= 5) ///
                {
                    this.star1.Fill = Brushes.Yellow;                                                 ////
                    this.star2.Fill = Brushes.Yellow;                                                 ///
                    this.star3.Fill = Brushes.Yellow;                                                 ////
                }



                string[] arr = new string[6];
                int      j   = 0;
                for (int i = 0; i < 9; i++)
                {
                    if (!(i == 1 || i == 6 || i == 7))
                    {
                        arr[j] = "05" + i;
                        if (arr[j] == this.nannyToUpdate._NumberOfphone.Substring(0, 3))
                        {
                            this.numberFonComboBox.SelectedItem = arr[j];
                        }
                        j++;
                    }
                }
                this.numberFonComboBox.ItemsSource = arr;

                this.FonNannyTaxtBox.Text = this.nannyToUpdate._NumberOfphone.Substring(3);
                this.userWorkHours.Show(this.nannyToUpdate.workHours);
            }
        }
 /// <summary>
 /// calculates the difference between moms request hours and the nanny scheduele
 /// </summary>
 /// <param name="nanny"></param>
 /// <param name="mom"></param>
 /// <returns></returns>
 public void schduleDifference(Nanny nanny, Mother mom)
 {
     nanny.diff = 0;
     for (int i = 0; i < 6; i++)
     {
         if (nanny.startHour[i] > mom.startHour[i])
         {
             TimeSpan sum = new TimeSpan();
             sum         = nanny.startHour[i] - mom.startHour[i];
             nanny.diff += ((sum.Days - 1) * 24 + sum.Hours + sum.Minutes / 60.0);
         }
         if (nanny.endHour[i] < mom.endHour[i])
         {
             TimeSpan sum = new TimeSpan();
             sum         = mom.endHour[i] - nanny.endHour[i];
             nanny.diff += ((sum.Days - 1) * 24 + sum.Hours + sum.Minutes / 60.0);
         }
     }
 }
Esempio n. 9
0
        /// <summary>
        /// add contract
        /// </summary>
        /// <param name="contract"></param>
        void IBL.AddContract(Contract contract)
        {
            // if it is the max amount of children for nanny
            Nanny           nanny = GetNanny(contract.NannyId);
            List <Contract> list  = MyDal.AllContracts().FindAll(item => item.NannyId == nanny.Id);

            if (list.Count() == nanny.MaxChildren)
            {
                throw new Exception("This is the maximum number of children!");
            }
            // if the contract already exist (the cild  already has a contract)
            Child child = GetChild(contract.ChildId);
            bool  flag  = true;

            foreach (Contract contract2 in MyDal.AllContracts())
            {
                if (child.Id == contract2.ChildId)
                {
                    flag = false;
                }
            }
            if (!flag)
            {
                throw new Exception("Contract already exist");
            }
            // if the begin date is after the end date
            if (contract.EndDate < contract.BeginDate)
            {
                throw new Exception("the contract ends before it begins");
            }
            // discount calculate
            Mother mother = GetMother(contract.MotherId);

            list = MyDal.AllContracts().FindAll(item => item.NannyId == nanny.Id && item.MotherId == mother.Id);
            double discount = 0;

            if (list.Count() != 0)
            {
                discount = (list.Count()) * 0.02;
            }
            contract.Salary = MonthlyPayment(contract) * (1 - discount);
            MyDal.AddContract(contract);
        }
Esempio n. 10
0
        public void addContract(Contract c)
        {
            XElement temp = ((from e in contracts.Elements()
                              where Convert.ToInt32(e.Element("ContractID").Value) == c.ContractID
                              select e).FirstOrDefault());

            if (temp != null)
            {
                throw new Exception("This contract already exist");
            }
            //apdate children of nanny
            Nanny n = getNanny(c.ID_nanny);

            n.myChildren.Add(getChild(c.ID_child));
            n.numOfChildren++;
            updateNanny(n);
            contracts.Add(BuildXelementContract(c));
            contracts.Save(ContractXml);
        }
Esempio n. 11
0
 /// <summary>
 /// update nanny
 /// </summary>
 /// <remarks></remarks>
 /// <param name="nanny">the new Nanny that replace the old nanny</param>
 /// <remarks>
 /// accept nanny, delete the old nanny and replace it with the new nanny
 /// if didn't find the nanny to delete, or can't add the new nanny throw exception
 /// </remarks>
 public void UpdateNanny(Nanny nanny)
 {
     if (FindNanny(nanny))
     {
         DeleteNanny(nanny);
         try
         {
             AddNanny(nanny);
         }
         catch (DALException)
         {
             throw new DALException("can't update " + nanny.FullName() + "details", "update nanny");
         }
     }
     else
     {
         throw new DALException(nanny.FullName() + " dosn't exsist", "update nanny");
     }
 }
Esempio n. 12
0
        public void addContract(Contract contract)
        {
            Nanny  n = dal.getNanny(contract.NannyID);
            Child  c = dal.getChild(contract.ChildID);
            Mother m = dal.getMom(c.MotherID);

            if (c.DateOfBirth.Year < 1 && c.DateOfBirth.Month < 3)
            {
                throw new Exception("the child's age is less than 3 month");
            }
            if (n.MaxChilds == (dal.GetAllContract().FindAll(x => x.NannyID == n.ID).Count))
            {
                throw new Exception("this nanny is full");
            }
            if (n.HourlyRate && (contract.HourOrMonth == BE.SalaryBy.Hour))
            {
                int hours = 0;
                for (int i = 0; i < 6; i++)
                {
                    hours += m.HoursOfNeedingNanny[1, i].Hour - m.HoursOfNeedingNanny[0, i].Hour;
                }
                contract.MonthlySalary = n.PricePerHour * 4 * hours;
            }
            else
            {
                contract.MonthlySalary = n.PricePerMonth;
            }

            int momChildren = dal.GetAllContract().FindAll(x => dal.getChild(x.ChildID).MotherID == m.ID && x.NannyID == n.ID).Count;

            for (int i = 0; i < momChildren; i++)
            {
                contract.MonthlySalary = contract.MonthlySalary * 0.02;
            }
            try
            {
                dal.addContract(contract);
            }
            catch (DuplicateWaitObjectException e)
            {
                throw new DuplicateWaitObjectException(e.Message);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Returns the grade of n according to her match to m
        /// The grade equal to the number of hours when n can work for m
        /// </summary>
        /// <param name="m">mother</param>
        /// <param name="n">nanny</param>
        /// <returns>the grade of n according to number of hours when n can work for m </returns>
        private TimeSpan GradeNannyToMother(Mother m, Nanny n)
        {
            TimeSpan grade = new TimeSpan(0, 0, 0);
            TimeSpan start, finish;

            for (int i = 0; i < 6; i++)
            {
                if (m.NeedNannyOnDay[i] && n.WorkOnDay[i])
                {
                    start  = (m.HoursForDay[i].Start > n.HoursOnDay[i].Start)?m.HoursForDay[i].Start: n.HoursOnDay[i].Start;
                    finish = (m.HoursForDay[i].Finish < n.HoursOnDay[i].Finish)? m.HoursForDay[i].Finish: n.HoursOnDay[i].Finish;
                    if (start < finish)
                    {
                        grade += finish - start;
                    }
                }
            }
            return(grade);
        }
Esempio n. 14
0
        public void updateNanny(Nanny existNanny)
        {
            bool flag   = false;
            var  result = from item in DataSource.nannies
                          where existNanny.Id == item.Id
                          select item;

            foreach (var item in result)
            {
                flag = true;
                DataSource.nannies.Remove(item);
                DataSource.nannies.Add(existNanny);
                break;
            }
            if (!flag)
            {
                throw new Exception("The nanny for update is not exist");
            }
        }
Esempio n. 15
0
 public void delNanny(Nanny temp)
 {
     // var temp = FindNanAcordId(id);
     if (temp != null)
     {
         if (GetAllContracts(c => c.IdNanny == temp.Id && c.EndDate < DateTime.Today).Any())
         {
             throw new Exception("The nanny has at least one valid contract.");
         }
         DataSource.nannies.Remove(temp);
         DataSource.contracs.RemoveAll(c => c.IdNanny == temp.Id);//remove old contracts
         saveListToXML(DS.DataSource.nannies, nannyPath);
         saveListToXML(DS.DataSource.contracs, contractPath);
     }
     else
     {
         throw new Exception("There is no such Nanny");
     }
 }
Esempio n. 16
0
        public void addContract(Contract contract)
        {
            var contractList = getContracts().ToList();

            if (contractList.Exists(c => c.idChild == contract.idChild && c.idNanny == contract.idNanny))
            {
                throw new Exception("Contract already exist in system, please update the contract");
            }
            Child  contractchild  = getChild(contract.idChild);
            Mother contractMother = getMom(contractchild.idMom);

            if (contractMother == null)
            {
                throw new Exception("Mother is not appear in the system");
            }
            Nanny contractNanny = getNanny(contract.idNanny);

            if (contractNanny == null)
            {
                throw new Exception("Nanny is not appear in system");
            }
            contract.idContract = ++contract_Id;

            XElement idContract     = new XElement("idContract", contract.idContract);
            XElement nameChild      = new XElement("name", contract.nameChild);
            XElement idChild        = new XElement("idChild", contract.idChild);
            XElement Child          = new XElement("Child", nameChild, idChild);
            XElement nameNanny      = new XElement("name", contract.nameNanny);
            XElement idNanny        = new XElement("idNanny", contract.idNanny);
            XElement Nanny          = new XElement("Nanny", nameNanny, idNanny);
            XElement isMet          = new XElement("isMet", contract.isMet);
            XElement isContract     = new XElement("isContract", contract.isContract);
            XElement salaryPerHour  = new XElement("salaryPerHour", contract.salaryPerHour);
            XElement salaryPerMonth = new XElement("salaryPerMonth", contract.salaryPerMonth);
            XElement salaryAgreed   = new XElement("salaryAgreed", contract.salaryAgreed);
            XElement isHour         = new XElement("isHour", contract.isHour);
            XElement workBegin      = new XElement("workBegin", contract.workBegin);
            XElement workEnd        = new XElement("workEnd", contract.workEnd);

            contractFile.Add(new XElement("contract", idContract, Child, Nanny, isMet, isContract, salaryPerHour,
                                          salaryPerMonth, salaryAgreed, isHour, workBegin, workEnd));
            contractFile.Save(contractPath);
        }
        public void updateNanny(Nanny nanny)
        {
            var  list = LoadFromXML <List <Nanny> >(nannyPath);
            bool flag = true;

            foreach (Nanny item in list)
            {
                if (item.Id == nanny.Id)//if find id to update
                {
                    flag = false;
                }
            }
            if (flag)//id to update not found throw Exception
            {
                throw new Exception("this nanny is not exist");
            }
            removeNanny(nanny); //delete the old mother
            addNanny(nanny);    //insert the update mother
        }
        public void addContract(Contract contract)
        {
            Child  contractChild  = dal.getChild(contract.idChild);
            Nanny  contractNanny  = dal.getNanny(contract.idNanny);
            Mother contractMother = dal.getMom(contractChild.idMom);
            //double discountRate = MomsKidsByNanny(contractChild, contractNanny) * 0.02 * contractNanny.rateMonthNanny;
            DateTime today = DateTime.Today;

            if (today.Year - contractChild.birthdayKid.Year < 1 && today.Month - contractChild.birthdayKid.Month < 3)
            {
                throw new Exception("Child is too small");
            }

            if (contractNanny.maxChildNanny == contractNanny.currentChildren)
            {
                throw new Exception("This nanny has reached the limit of children");
            }
            dal.addContract(contract);
        }
Esempio n. 19
0
        public void Remove_Nanny(Nanny n)
        {
            Nanny nanny = new Nanny();
            bool  check = true;

            foreach (Nanny item in DataSource.Nannies)
            {
                if (item.ID == n.ID)
                {
                    check = false;
                    nanny = item;
                }
            }
            if (check)
            {
                throw new Exception("This Nanny does not exist!");
            }
            DataSource.Nannies.Remove(nanny);
        }
Esempio n. 20
0
        /// <summary>
        /// returns the top 5 closest to suitable nannies for the parameter mother
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public Nanny[] Top5Nannies(Mother m)
        {
            Nanny[]             ret       = new Nanny[5];
            IEnumerable <Nanny> suitables = SuitableNannies(m);
            int i = 0;

            foreach (Nanny n in suitables)
            {
                ret[i++] = n;
                if (i == 5)
                {
                    return(ret);
                }
            }
            Nanny[] temp = new Nanny[5 - i]; // the remaining not suitable nannies will be here
            foreach (Nanny n in GetNannies())
            {
                if (!(TotalHours(IntersectHours(n, m)) >= TotalHours(m.HoursNeeded)))                                                                               // if the nanny isn't suitable
                {
                    for (int j = 0; j < 5 - i; j++)                                                                                                                 // finding a position for the nanny n in "temp"
                    {
                        if (TotalHours(IntersectHours(n, m)) > 0 && (temp[j] == null || TotalHours(IntersectHours(n, m)) > TotalHours(IntersectHours(temp[j], m)))) // if n is better than temp[j]
                        {
                            for (int k = j; k < 4 - i; k++)                                                                                                         // push the whole array forward (last nanny is removed)
                            {
                                temp[k + 1] = temp[k];
                            }
                            temp[j] = n; // and insert the n nanny
                            break;
                        }
                    }
                }
            }
            for (int j = 0; i < 5; i++) // merges ret with temp
            {
                ret[i] = temp[j++];
            }
            //for (int j = 4; j > 0; j--) // the lazy but working way to remove duplicates
            //    if (ret[j] == ret[j - 1])
            //        ret[j] = null;
            return(ret);
        }
Esempio n. 21
0
        public void addContract(Contract contract)
        {
            int number = r.Next(100000000, 399999999);

            while (findContract(number) != null)
            {
                number = r.Next(100000000, 399999999);
            }
            contract.contract_number = number;

            Mother mom = findMother(contract.mother_ID);
            Nanny  nan = findNanny(contract.nanny_ID);

            if (nan == null || mom == null)
            {
                throw new Exception("error in nanny or mother id...");
            }

            DS.DataSourse.listOfConntracts.Add(contract);
        }
Esempio n. 22
0
 /// <summary>
 /// update the numabr of nanny's children
 /// </summary>
 /// <param name="nanny">the nanny that we whnt to update her children number</param>
 /// <param name="num">flag, if num = 1 add 1 else sub 1 </param>
 /// <remarks>
 /// accept nanny and a number
 /// if number = 1, add 1 to nanny's children
 /// else reduce nanny's children by 1
 /// if didn't find the nanny throw exception
 /// </remarks>
 public void UpdateNannyChildren(Nanny nanny, int?num)
 {
     if (FindNanny(nanny))
     {
         if (num == 1)
         {
             // add 1
             NannyList().Find(nan => nan.Equals(nanny)).Children++;
         }
         else
         {
             //reduce by 1
             NannyList().Find(nan => nan.Equals(nanny)).Children--;
         }
     }
     else
     {
         throw new DALException(nanny.FullName() + " dosn't exsist", "AddNannyChildren");
     }
 }
Esempio n. 23
0
        public void addNanny(Nanny newNanny)
        {
            bool flag   = true;
            var  result = from item in DataSource.nannies
                          where newNanny.Id == item.Id
                          select item;

            foreach (Nanny item in result)
            {
                flag = false;
            }
            if (!flag)
            {
                throw new Exception("The nanny is already exist.");
            }
            else
            {
                DataSource.nannies.Add(newNanny);
            }
        }
        public void AddNanny(Nanny inputNanny)
        {
            DateTime age = inputNanny.NannyDateOfBirth;

            age.AddYears(18);
            if (DateTime.Now < age)
            {
                throw new Exception("Can't add Nanny under 18 age");
            }

//checks if id is correct
            if (!BlTools.IsCorrectId(inputNanny.NannyId))
            {
                throw new Exception("Error ID, please enter ID with 6 to 9 numbers");
            }



            dal.AddNanny(inputNanny);
        }
Esempio n. 25
0
        /// <summary>
        /// removes a nanny from DS
        /// </summary>
        /// <param name="nanny"></param>
        public void deleteNanny(Nanny nanny)
        {
            if (!isNannyInList(nanny.id))
            {
                throw new Exception("nanny is not in list\n");
            }

            // deletes all contracts associated with nanny
            IEnumerable <Contract> nannyContracts = ListOfContractsById(nanny.id);

            if (nannyContracts != null)
            {
                foreach (Contract c in nannyContracts.ToList())
                {
                    deleteContract(c);
                }
            }

            DataSource.listOfNannys.Remove(nanny);
        }
Esempio n. 26
0
        /// <summary>
        /// delete nanny
        /// </summary>
        /// <param name="ID"></param>
        void Idal.DeleteNanny(string ID)
        {
            Nanny nanny2 = GetNanny(ID);

            if (nanny2.Id == null)
            {
                throw new Exception("Nanny doesn't exist");
            }
            DataSource.listNanny.Remove(nanny2);
            // delete the contracts she related to
            List <Contract> contracts = GetContractsByID(nanny2.Id);

            if (contracts != null)
            {
                foreach (Contract contract in contracts)
                {
                    DataSource.listContract.Remove(contract);
                }
            }
        }
Esempio n. 27
0
        public void deleteContract(long idChildContractDel)
        {
            LoadData("contract");

            XElement contractElement;

            contractElement = (from contr in contractFile.Elements()
                               where int.Parse(contr.Element("Child").Element("idChild").Value) == idChildContractDel
                               select contr).FirstOrDefault();
            if (contractElement == null)
            {
                return;
            }
            Nanny contracctNanny = getNanny(long.Parse(contractElement.Element("Nanny").Element("idNanny").Value));

            contracctNanny.currentChildren--;
            updateNanny(contracctNanny);
            contractElement.Remove();
            contractFile.Save(contractPath);
        }
        public double getSalary(long idChild, long idNanny, bool isHour, bool isUpdate)
        {
            Child  contractChild  = dal.getChild(idChild);
            Nanny  contractNanny  = dal.getNanny(idNanny);
            Mother contractMother = dal.getMom(contractChild.idMom);
            double discountRate   = MomsKidsByNanny(contractChild, contractNanny) * 0.02;

            if (isUpdate == true)
            {
                discountRate -= 0.02;
            }
            if (isHour == false)
            {
                return(contractNanny.rateMonthNanny - contractNanny.rateMonthNanny * discountRate);
            }
            else
            {
                return(getMomHours(contractMother) * 4 * contractNanny.rateHourNanny - getMomHours(contractMother) * contractNanny.rateHourNanny * 4 * discountRate);
            }
        }
Esempio n. 29
0
        /// <summary>
        /// initialMatch - Returns the nannies who are fit to specific terms
        /// </summary>
        /// <param name="parent">the parent</param>
        /// <param name="gender">the gender of the desired nanny</param>
        /// <param name="skill">the skills the parent wants in the nanny</param>
        /// <param name="languages">the languages the nanny should know</param>
        /// <param name="minExpYears">the minimum years of experience the parent expect from the nanny</param>
        /// <param name="spec">the nannies specialization the parent needs </param>
        /// <param name="maxCostPerHour">the maximum cost the parrent afford to pay</param>
        /// <param name="liftInBuilding">if it is important to the parent - lift in the buildiing</param>
        /// <param name="tamatHoliday">if the parent wants the tamat holiday</param>
        /// <param name="minStars">minimum nannies score the parent wants </param>
        /// <returns>list of the nannies with the better match</returns>
        /// <returns>initial list of Appropriate nannies</returns>

        //help function to initial match
        private bool checkHours(Nanny nanny, Parent parent)
        {
            //The function checks fittness between the nanny work-hours anfd the parent recuirement
            foreach (var day in parent.parentWorkhours)//Check if nanny work in all the hours the parents require
            {
                if (nanny.workhours.ContainsKey(day.Key))
                {
                    //Check nanny doesn't start later of finish earlier than the parents need.
                    if (nanny.workhours[day.Key].Key > day.Value.Key || nanny.workhours[day.Key].Value < day.Value.Value)
                    {
                        return(false);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Esempio n. 30
0
        public void RemoveNanny(int id)
        {
            DAL_XML_Imp b = new DAL_XML_Imp();
            //Nanny nann = GetNanny(id);
            Nanny nann = b.GetNanny(id);

            if (nann == null)
            {
                throw new Exception("Nanny with the same id not found...");
            }
            b.RemoveNanny(id);
            //DataSource.NannyList.RemoveAll(n => n.ID == id);

            //DataSource.NannyList.Remove(nann);
            //IEnumerable<Contract> contractsofNanny = getContractList(x => x.Nanny_ID == id);
            //foreach (Contract contr in contractsofNanny.ToList())
            //{
            //    RemoveContract(contr.Contract_ID);
            //}
        }