Example #1
0
        public List <ModelPlans> Get(int id)
        {
            plans plan = null;

            plan = db.plans.Find(id);
            List <ModelPlans> lista = new List <ModelPlans>();

            if (plan != null)
            {
                ModelPlans temp = new ModelPlans(plan);
                transport  t    = null;
                t = db.transport.Find(plan.transport_id);
                if (t != null)
                {
                    locations l = null;
                    l = db.locations.Find(t.end_id);
                    if (l != null)
                    {
                        temp.destination = l.loc_name;
                    }
                }
                hotels h = null;
                h = db.hotels.Find(plan.hotel_id);
                if (h != null)
                {
                    temp.hotel_name = h.hotel_name;
                }
                lista.Add(temp);
            }

            return(lista);
        }
Example #2
0
        private void StatisticsPrijevozi(int hotel_id, int source_id)
        {
            statistics_transport sf = new statistics_transport();

            List <statistics_transport> sfCheck = db.statistics_transport.Where(x => x.source_id.Equals(source_id) && x.hotel_id == hotel_id).ToList();

            if (sfCheck.Count() > 0)
            {
                sf = sfCheck.First();
                if (sf.cnt != null)
                {
                    sf.cnt = sf.cnt + 1;
                }
                else
                {
                    sf.cnt = 1;
                }
            }
            else
            {
                sf.hotel_id  = hotel_id;
                sf.source_id = source_id;
                sf.cnt       = 1;

                hotels h = null;
                h             = db.hotels.Find(hotel_id);
                sf.hotel_name = h.hotel_name;

                db.statistics_transport.Add(sf);
            }

            db.SaveChanges();
        }
Example #3
0
        public List <ModelPlans> Get()
        {
            List <ModelPlans> lista  = new List <ModelPlans>();
            List <plans>      dbList = db.plans.ToList();

            foreach (plans loc in dbList)
            {
                ModelPlans temp = new ModelPlans(loc);
                transport  t    = null;
                t = db.transport.Find(loc.transport_id);
                if (t != null)
                {
                    locations l = null;
                    l = db.locations.Find(t.end_id);
                    if (l != null)
                    {
                        temp.destination = l.loc_name;
                    }
                }
                hotels h = null;
                h = db.hotels.Find(loc.hotel_id);
                if (h != null)
                {
                    temp.hotel_name = h.hotel_name;
                }
                lista.Add(temp);
            }

            return(lista);
        }
Example #4
0
        public void checkDelTour()
        {
            countries contr = new countries();

            countries.dataCountries.Rows.Add("1", "Америка");
            Countries_Col obj = new Countries_Col();

            hotels hot = new hotels();

            hotels.dataHotels.Rows.Add("1", "hotel", "****", "12000");
            HotelFactory hotelfac = new HotelFactory();

            tours formTour = new tours();

            tours.dataTours.Rows.Add("1", "tour", "VIP туры", "Россия", "True", "hotel", "Автобус", "BB", "12000", "Рубль");
            tours.dataTours.Rows.Add("2", "tour", "VIP туры", "Россия", "True", "hotel", "Автобус", "BB", "12000", "Рубль");
            tours.dataTours.Rows.Add("3", "tour", "VIP туры", "Россия", "True", "hotel", "Автобус", "BB", "12000", "Рубль");

            FoodCol      food     = new FoodCol();
            TransportCol tr       = new TransportCol();
            TourTypeCol  tourtype = new TourTypeCol();

            TourFactory factTour = new TourFactory();
            int         a        = TourFactory.count();

            TourFactory.DeleteTour(1);
            Assert.AreEqual(a - 1, TourFactory.count());
        }
        private void StatisticsActivities(string naziv, int hotel_id)
        {
            statistics_activities sf = new statistics_activities();

            List<statistics_activities> sfCheck = db.statistics_activities.Where(x => x.naziv.Equals(naziv) && x.hotel_id == hotel_id).ToList();
            if (sfCheck.Count() > 0)
            {
                sf = sfCheck.First();
                if (sf.cnt != null)
                {
                    sf.cnt = sf.cnt + 1;
                }
                else
                {
                    sf.cnt = 1;
                }
            }
            else
            {
                sf.hotel_id = hotel_id;
                sf.naziv = naziv;
                sf.cnt = 1;

                hotels h = null;
                h = db.hotels.Find(hotel_id);
                sf.hotel_name = h.hotel_name;

                db.statistics_activities.Add(sf);
            }

            db.SaveChanges();
        }
Example #6
0
        public async Task <List <ModelPlans> > Post()
        {
            string result = await Request.Content.ReadAsStringAsync();

            List <ModelPlans> newList = new List <ModelPlans>();

            dynamic jobj = JsonConvert.DeserializeObject(result);

            plans newPlan = new plans();

            newPlan.plan_naziv   = jobj.plan_name;
            newPlan.transport_id = jobj.transport_id;
            newPlan.hotel_id     = jobj.hotel_id;

            db.plans.Add(newPlan);

            int   userId = jobj.user_id;
            users user   = null;

            user = db.users.Find(userId);
            if (user != null)
            {
                user.plans.Add(newPlan);
            }

            db.SaveChanges();

            ModelPlans temp = new ModelPlans(newPlan);
            transport  t    = null;

            t = db.transport.Find(newPlan.transport_id);
            if (t != null)
            {
                locations l = null;
                l = db.locations.Find(t.end_id);
                if (l != null)
                {
                    temp.destination = l.loc_name;
                }
            }
            hotels h = null;

            h = db.hotels.Find(newPlan.hotel_id);
            if (h != null)
            {
                temp.hotel_name = h.hotel_name;
            }
            newList.Add(temp);

            //StatisticsPrijevozi(newPlan.hotel_id.Value, db.transport.Find(newPlan.transport).start_id.Value);

            return(newList);
        }
Example #7
0
        public void checkAddOrder()
        {
            string[] order = new string[7];
            order[0] = "225";
            order[1] = "Petr";
            order[2] = "Vasya";
            order[3] = "12 may 2013";
            order[4] = "tour";

            clients formCL = new clients();

            clients.dataClients.Rows.Add("1", "Pet", "*****@*****.**", "88-88", "12 may 1990", "true", "VIP");
            ClientTypeCol col    = new ClientTypeCol();
            ClientFactory factCl = new ClientFactory();

            managers formMan = new managers();

            managers.dataManagers.Rows.Add("1", "Petya", "8888", "Менеджер", "petya");
            ManagerTypeCol coll    = new ManagerTypeCol();
            ManagerFactory factMan = new ManagerFactory();

            orders formOrd = new orders();

            orders.dataOrders.Rows.Add("Pet", "Petya", "12 may 2015", "1", "tour1");
            orders.dataOrders.Rows.Add("Pet", "Petya", "13 may 2014", "2", "tou2");
            orders.dataOrders.Rows.Add("Pet", "Petya", "14 may 2014", "3", "tou3");

            countries contr = new countries();

            countries.dataCountries.Rows.Add("1", "Россия");
            Countries_Col obj = new Countries_Col();

            hotels hot = new hotels();

            hotels.dataHotels.Rows.Add("1", "hotel", "****", "12000");
            HotelFactory hotelfac = new HotelFactory();

            FoodCol      food     = new FoodCol();
            TransportCol tr       = new TransportCol();
            TourTypeCol  tourtype = new TourTypeCol();

            tours formTour = new tours();

            tours.dataTours.Rows.Add("1", "tour", "VIP туры", "Россия", "true", "hotel", "Автобус", "BB", "12000", "Рубль");
            TourFactory  factTour = new TourFactory();
            OrderFactory fact     = new OrderFactory();
            int          a        = OrderFactory.count();

            OrderFactory.AddOrder(order);
            Assert.AreEqual(a + 1, OrderFactory.count());
        }
Example #8
0
        public async Task <statistics_food> Post()
        {
            string result = await Request.Content.ReadAsStringAsync();

            List <ModelActivities> newList = new List <ModelActivities>();

            dynamic jobj     = JsonConvert.DeserializeObject(result);
            int     users_id = jobj.users_id;
            int     hotel_id = jobj.hotel_id;
            string  naziv    = jobj.naziv;

            statistics_food sf = new statistics_food();

            List <statistics_food> sfCheck = db.statistics_food.Where(x => x.naziv.Equals(naziv) && x.hotel_id == hotel_id).ToList();

            if (sfCheck.Count() > 0)
            {
                sf = sfCheck.First();
                if (sf.cnt != null)
                {
                    sf.cnt = sf.cnt + 1;
                }
                else
                {
                    sf.cnt = 1;
                }
            }
            else
            {
                sf.users_id = users_id;
                sf.hotel_id = hotel_id;
                sf.naziv    = naziv;
                sf.cnt      = 1;

                hotels h = null;
                h             = db.hotels.Find(hotel_id);
                sf.hotel_name = h.hotel_name;

                db.statistics_food.Add(sf);
            }

            db.SaveChanges();

            return(sf);
        }
Example #9
0
        public List <ModelActivities> Get(int id)
        {
            hotels hotelFilter = null;

            hotelFilter = db.hotels.Find(id);
            List <ModelActivities> lista  = new List <ModelActivities>();
            List <activities>      dbList = new List <activities>();

            if (hotelFilter != null)
            {
                dbList.AddRange(hotelFilter.activities);
                foreach (activities x in dbList)
                {
                    ModelActivities temp = new ModelActivities(x);
                    lista.Add(temp);
                }
            }

            return(lista);
        }
Example #10
0
        public List <ModelPlans> Get(int id)
        {
            users userFilter = null;

            userFilter = db.users.Find(id);
            List <plans>      dbList = new List <plans>();
            List <ModelPlans> lista  = new List <ModelPlans>();

            if (userFilter != null)
            {
                dbList.AddRange(userFilter.plans);
                foreach (plans loc in dbList)
                {
                    ModelPlans ml = new ModelPlans(loc);

                    hotels h = null;
                    h = db.hotels.Find(ml.hotel_id);
                    if (h != null)
                    {
                        ml.hotel_name = h.hotel_name;
                    }

                    transport t = null;
                    t = db.transport.Find(ml.transport_id);
                    if (t != null)
                    {
                        locations l = null;
                        l = db.locations.Find(t.end_id);
                        if (l != null)
                        {
                            ml.destination = l.loc_name;
                        }
                    }

                    lista.Add(ml);
                }
            }

            return(lista);
        }
Example #11
0
        public void checkAddTour()
        {
            string[] tour = new string[10];
            tour[0] = "2";
            tour[1] = "tour1";
            tour[2] = "VIP туры";
            tour[3] = "true";
            tour[4] = "hotel";
            tour[5] = "Авиа";
            tour[6] = "HB";
            tour[7] = "35500";
            tour[8] = "Доллар";
            tour[9] = "Америка";

            countries contr = new countries();

            countries.dataCountries.Rows.Add("1", "Америка");
            Countries_Col obj = new Countries_Col();

            hotels hot = new hotels();

            hotels.dataHotels.Rows.Add("1", "hotel", "****", "12000");
            HotelFactory hotelfac = new HotelFactory();

            tours formTour = new tours();

            tours.dataTours.Rows.Add("1", "tour", "VIP туры", "Россия", "True", "hotel", "Автобус", "BB", "12000", "Рубль");

            FoodCol      food     = new FoodCol();
            TransportCol tr       = new TransportCol();
            TourTypeCol  tourtype = new TourTypeCol();

            TourFactory factTour = new TourFactory();
            int         a        = TourFactory.count();

            TourFactory.Add_Tour(tour);
            Assert.AreEqual(a + 1, TourFactory.count());
        }