예제 #1
0
파일: BL.cs 프로젝트: israelZ/restMeng
        public List <Client> get_client_list()
        {
            XDal = FactorySingletonDal.getInstanceDal();
            List <Client> send = new List <Client>(XDal.get_client_list());

            return(send);
        }
예제 #2
0
파일: BL.cs 프로젝트: israelZ/restMeng
        // GET
        public List <Branch> get_branch_list()
        {
            XDal = FactorySingletonDal.getInstanceDal();
            List <Branch> send = new List <Branch>(XDal.get_branch_list());

            return(send);
        }
예제 #3
0
파일: BL.cs 프로젝트: israelZ/restMeng
        public List <Ordered_Dish> get_order_dish_list()
        {
            XDal = FactorySingletonDal.getInstanceDal();
            List <Ordered_Dish> send = new List <Ordered_Dish>(XDal.get_order_dish_list());

            return(send);
        }
예제 #4
0
파일: BL.cs 프로젝트: israelZ/restMeng
        /// <summary>
        /// by a given branch the function will return all the information
        /// on the orders they made per order
        /// </summary>
        /// <param name="Br"></param>
        /// <returns></returns>
        public List <List <string_int> > Brach_order_history(Branch Br)/*4*/
        {
            /// dish name, quantitiy, price
            /// note - firt element in a list holds time_stamp and order bill
            XDal = FactorySingletonDal.getInstanceDal();

            List <Order> tmp_order_dish        = new List <Order>(XDal.get_order_list());
            List <List <string_int> > all_info = new List <List <string_int> >();
            List <string_int>         tmp      = new List <string_int>();


            var found =
                from orders in tmp_order_dish
                where orders.Get_branch_id == Br.Get_Branch_id
                select orders;

            foreach (var an_orders in found)
            {
                tmp = Orders_info(an_orders);
                tmp.First().time     = an_orders.Get_time;
                tmp.First().o_number = oreder_bill(an_orders);
                all_info.Add(tmp);
            }

            return(all_info);
        }
예제 #5
0
        public bool AddTester(Tester tester)
        {
            //if tester is to young
            if (DateTime.Now.Year - tester.DateOfBirth.Year < Configuration.minTesterAge)
            {
                throw new Exception("A tester cannot be under " + Configuration.minTesterAge + " years old /n");
            }
            //if tester is to old
            if (DateTime.Now.Year - tester.DateOfBirth.Year > Configuration.MaxTesterAge)
            {
                throw new Exception("A tester cannot be over " + Configuration.minTesterAge + " years old /n");
            }
            try
            {
                IDal _dal = FactorySingletonDal.GetDal();
                if (_dal.AddTester(tester))
                {
                    return(true);
                }
                return(false);
            }

            catch (Exception e)
            {
                throw e;
            }
        }
예제 #6
0
파일: BL.cs 프로젝트: israelZ/restMeng
        /// <summary>
        /// returns a list of (group_local: temp class)
        /// which contains a info on every Location its total profit
        /// </summary>
        /// <returns></returns>
        public List <group_local> Profits_by_location()
        {
            XDal = FactorySingletonDal.getInstanceDal();

            List <Order>       orders = new List <Order>(XDal.get_order_list());
            List <group_local> mini   = new List <group_local>();
            var local =
                from grp in orders
                group grp by grp.get_location
                into location
                select location;

            foreach (var grp in local)
            {
                double sum_p = 0;
                foreach (var order in grp)
                {
                    sum_p += oreder_bill(order);
                }
                group_local tmp = new group_local();
                tmp.local = grp.First().get_location;
                tmp.sum_p = sum_p;
                mini.Add(tmp);
            }
            return(mini);
        }
예제 #7
0
파일: BL.cs 프로젝트: israelZ/restMeng
        /// <summary>
        /// returns a list of (group_time: temp class)
        /// which contains a info on every Date its total profit
        /// </summary>
        /// <returns></returns>
        public List <group_time> time_Profits()
        {
            XDal = FactorySingletonDal.getInstanceDal();

            List <Order>      tmplist = new List <Order>(XDal.get_order_list());
            List <group_time> grp     = new List <group_time>();
            double            sum_p   = 0;

            var order_group =
                from date in tmplist
                group date by date.Get_time.Date
                into time
                select time;

            foreach (var date in order_group)
            {
                foreach (var order in date)
                {
                    sum_p += oreder_bill(order);
                }
                group_time tmp = new group_time {
                    sum_p = sum_p, date = date.First().Get_time
                };
                grp.Add(tmp);
            }
            foreach (var item in grp)
            {
                Console.WriteLine(item.date + " " + item.sum_p);
                Console.WriteLine();
            }
            return(grp);
        }
예제 #8
0
파일: BL.cs 프로젝트: israelZ/restMeng
        /// <summary>
        /// returns a list of (group_Order_dish: temp class)
        /// which contains a info on every Dish its total profit
        /// </summary>
        /// <returns></returns>
        public List <group_Order_dish> dish_Profits()
        {
            XDal = FactorySingletonDal.getInstanceDal();

            List <Ordered_Dish>     tmplist   = new List <Ordered_Dish>(XDal.get_order_dish_list());
            List <group_Order_dish> DishGroup = new List <group_Order_dish>();
            var item =
                from grp in tmplist
                group grp by search_d(grp.get_dish_id).Get_name into dishes
                select dishes;

            foreach (var grp in item)
            {
                double sum_p = 0;
                int    sum_q = 0;
                foreach (var dish in grp)
                {
                    sum_p += search_d(dish.get_dish_id).get_price *dish.get_quantity;
                    sum_q += dish.get_quantity;
                }
                group_Order_dish group = new group_Order_dish();

                var sumes = new { search_d(grp.First().get_dish_id).Get_name };
                group.name  = sumes.Get_name;
                group.sum_p = sum_p;
                group.sum_q = sum_q;
                DishGroup.Add(group);
            }
            return(DishGroup);
        }
예제 #9
0
파일: BL.cs 프로젝트: israelZ/restMeng
        /*Requested*/
        /// <summary>
        /// sums the total profit\bill of a certain order
        /// </summary>
        /// <param name="Or">Order</param>
        /// <returns></returns>
        public double oreder_bill(Order Or) // by id order we find ordered meals
        {
            XDal = FactorySingletonDal.getInstanceDal();

            List <Ordered_Dish> tmp  = new List <Ordered_Dish>(XDal.get_order_dish_list());
            List <int>          tmpi = new List <int>(Or.get_list);
            double sum = 0;
            int    t_id;

            while (tmpi.Any())
            {
                t_id = tmpi.First();

                var item =
                    from dish in tmp
                    where dish.Get_D_Order_code == t_id
                    select dish;

                foreach (var orderes in item)
                {
                    sum += ((XDal.search_d(orderes.get_dish_id).get_price) * orderes.get_quantity);
                }

                tmpi.Remove(t_id);
            }
            return(sum);
        }
예제 #10
0
파일: BL.cs 프로젝트: israelZ/restMeng
        /// <summary>
        /// gets a List of order_dish's ids and returns total clories
        /// </summary>
        /// <param name="mylist">order_dish's ids</param>
        /// <returns></returns>
        public int All_Calories(List <int> mylist)/*6*/
        {
            XDal = FactorySingletonDal.getInstanceDal();

            int Calories = 0;

            if (mylist != null)
            {
                List <Ordered_Dish> order_d_l = new List <Ordered_Dish>(XDal.get_order_dish_list());
                List <int>          ids       = new List <int>(mylist);

                while (ids.Any())
                {
                    var bl = from n in order_d_l
                             where n.Get_D_Order_code == ids.First()
                             select n;

                    foreach (var item in bl)
                    {
                        Calories += item.get_quantity * (XDal.search_d(item.get_dish_id).get_cal);
                    }

                    ids.Remove(ids.First());
                }
            }

            return(Calories);
        }
예제 #11
0
        public bool AddDrivingTest(Test test)
        {
            Trainee helpTrainee = GetTrainees().FirstOrDefault(t => t.ID == test.TraineeID);
            Tester  helpTester  = GetTesters().FirstOrDefault(t => t.ID == test.TesterID);


            //get all trainee tests. the last test will be first;
            var TraineeTests = ((from t in GetTests()
                                 where t.TraineeID == test.TraineeID
                                 select t).OrderByDescending(t => test.TestDay.Year)
                                .ThenByDescending(t => test.TestDay.Month)
                                .ThenByDescending(t => test.TestDay.Day).ToList());

            //check there is enough days between tests
            if (TraineeTests.Any())
            {
                TimeSpan ts = test.TestDay - TraineeTests.First().TestDay;
                if (ts.Days < Configuration.daysBetweenTests)
                {
                    throw new Exception("There must be at least " + Configuration.daysBetweenTests + " days before a trainee can take another test\n");
                }
            }
            //check trainee took enough lessons
            if (helpTrainee.NumOfLessons < Configuration.minLessons)
            {
                throw new Exception("A trainee cannot take a test if he took less than" + Configuration.minLessons + " lessons\n");
            }
            //find all tests trainee succedded
            var licence = from t in GetTests()
                          where t.TraineeID == test.TraineeID && t.TestResult == true
                          select t;

            //check if trainee already have a licence to this type of car
            foreach (var item in licence)
            {
                if (item.Vehicle == test.Vehicle)
                {
                    throw new Exception("Trainee already has licence for this type of car");
                }
            }

            try
            {
                IDal _dal = FactorySingletonDal.GetDal();
                if (_dal.AddDrivingTest(test))
                {
                    helpTester.NumOfTests++;
                    helpTrainee.NumOfTests++;
                    return(true);
                }
                return(false);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #12
0
파일: BL.cs 프로젝트: israelZ/restMeng
 public bool update_ordered_d(Ordered_Dish Or)
 {
     XDal = FactorySingletonDal.getInstanceDal();
     if (XDal.update_ordered_d(Or))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #13
0
파일: BL.cs 프로젝트: israelZ/restMeng
 public bool cancel_order(Order O)
 {
     XDal = FactorySingletonDal.getInstanceDal();
     if (XDal.cancel_order(O))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #14
0
파일: BL.cs 프로젝트: israelZ/restMeng
 public bool update_branch(Branch B)
 {
     XDal = FactorySingletonDal.getInstanceDal();
     if (XDal.update_branch(B))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #15
0
파일: BL.cs 프로젝트: israelZ/restMeng
 public bool update_dish(Dish D)
 {
     XDal = FactorySingletonDal.getInstanceDal();
     if (XDal.update_dish(D))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #16
0
파일: BL.cs 프로젝트: israelZ/restMeng
 public bool update_client(Client Cl)
 {
     XDal = FactorySingletonDal.getInstanceDal();
     if (XDal.update_client(Cl))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #17
0
 public bool UpdateTester(Tester tester)
 {
     try
     {
         IDal _dal = FactorySingletonDal.GetDal();
         _dal.UpdateTester(tester);
     }
     catch (Exception e)
     {
         throw e;
     }
     return(true);
 }
예제 #18
0
 public bool UpdateTrainee(Trainee trainee)
 {
     try
     {
         IDal _dal = FactorySingletonDal.GetDal();
         _dal.UpdateTrainee(trainee);
     }
     catch (Exception e)
     {
         throw e;
     }
     return(true);
 }
예제 #19
0
 public bool RemoveTester(string testerID)
 {
     try
     {
         IDal _dal = FactorySingletonDal.GetDal();
         _dal.RemoveTester(testerID);
     }
     catch (Exception e)
     {
         throw e;
     }
     return(true);
 }
예제 #20
0
 public bool UpdateDrivingTest(Test test)
 {
     try
     {
         IDal _dal = FactorySingletonDal.GetDal();
         _dal.UpdateDrivingTest(test);
         return(true);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #21
0
파일: BL.cs 프로젝트: israelZ/restMeng
        public Dish search_d(int ID)
        {
            Dish send = new Dish()
            {
                Get_Dish_id = 0
            };

            if (Tools.isNumeric(ID.ToString()))
            {
                XDal = FactorySingletonDal.getInstanceDal();
                send = (Dish)XDal.search_d(ID).Clone();
            }
            return(send);
        }
예제 #22
0
파일: BL.cs 프로젝트: israelZ/restMeng
        public Branch search_b(int ID)
        {
            Branch send = new Branch()
            {
                Get_Branch_id = 0
            };

            if (Tools.isNumeric(ID.ToString()))
            {
                XDal = FactorySingletonDal.getInstanceDal();
                send = (Branch)XDal.search_b(ID).Clone();
            }
            return(send);
        }
예제 #23
0
파일: BL.cs 프로젝트: israelZ/restMeng
        public Order search_o(int code)
        {
            Order send = new Order()
            {
                Get_Order_code = 0
            };

            if (Tools.isNumeric(code.ToString()))
            {
                XDal = FactorySingletonDal.getInstanceDal();
                send = (Order)XDal.search_o(code).Clone();
            }
            return(send);
        }
예제 #24
0
파일: BL.cs 프로젝트: israelZ/restMeng
        public Ordered_Dish search_o_d(int id)
        {
            Ordered_Dish send = new Ordered_Dish()
            {
                Get_D_Order_code = 0
            };

            if (Tools.isNumeric(id.ToString()))
            {
                XDal = FactorySingletonDal.getInstanceDal();
                send = (Ordered_Dish)XDal.search_o_d(id).Clone();
            }
            return(send);
        }
예제 #25
0
파일: BL.cs 프로젝트: israelZ/restMeng
        public Client search_cus(int id)
        {
            Client send = new Client()
            {
                Get_Cus_id = 0
            };

            if (Tools.isNumeric(id.ToString()))
            {
                XDal = FactorySingletonDal.getInstanceDal();
                send = (Client)XDal.search_cus(id).Clone();
            }
            return(send);
        }
예제 #26
0
 public bool RemovedrivingTest(int serialNumber)
 {
     try
     {
         IDal _dal = FactorySingletonDal.GetDal();
         if (_dal.RemovedrivingTest(serialNumber))
         {
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #27
0
파일: BL.cs 프로젝트: israelZ/restMeng
        /// <summary>
        /// gets a location and returns a list of all the available branches in that area
        /// </summary>
        /// <param name="luc"></param>
        /// <returns></returns>
        public List <Branch> available_b(Location luc)/*2*/
        {
            XDal = FactorySingletonDal.getInstanceDal();

            List <Branch> tmp_list = new List <Branch>(XDal.get_branch_list());
            List <Branch> ava_b    = new List <Branch>();

            var item = tmp_list.Where(i => i.get_location == luc);

            foreach (var branch in item)
            {
                ava_b.Add(branch);
            }

            return(ava_b);
        }
예제 #28
0
        public bool RemoveTrainee(string traineeID)
        {
            IDal _dal = FactorySingletonDal.GetDal();

            try
            {
                if (_dal.RemoveTrainee(traineeID))
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #29
0
파일: BL.cs 프로젝트: israelZ/restMeng
        /// <summary>
        ///gets a kosher's and returns a list of branches in that supervision
        /// </summary>
        /// <param name="sup"></param>
        /// <returns></returns>
        public List <Branch> find_by_kosher(Supervision sup)/*5*/
        {
            XDal = FactorySingletonDal.getInstanceDal();

            List <Branch> all_branches = new List <Branch>(XDal.get_branch_list());
            List <Branch> available    = new List <Branch>();

            var avail =
                from branch in all_branches
                where branch.Get_kosher == sup
                select branch;

            foreach (var found in avail)
            {
                available.Add(found);
            }

            return(available);
        }
예제 #30
0
 public bool AddTrainee(Trainee trainee)
 {
     //if trainee is to young
     if (DateTime.Now.Year - trainee.DateOfBirth.Year < Configuration.minTraineeAge)
     {
         throw new Exception("A trainee cannot be under " + Configuration.minTraineeAge + " years old \n");
     }
     try
     {
         IDal _dal = FactorySingletonDal.GetDal();
         if (_dal.AddTrainee(trainee))
         {
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
         throw e;
     }
 }