Exemple #1
0
        public void checkAddManager()
        {
            //new manager
            string[] manager = new string[5];
            manager[0] = "125";
            manager[1] = "John";
            manager[2] = "893-88";
            manager[3] = "Генеральный директор";
            manager[4] = "user";

            //create form with table
            managers form = new managers();

            //add 3 records
            managers.dataManagers.Rows.Add("1", "Petya", "8888", "Менеджер", "petya");
            managers.dataManagers.Rows.Add("2", "Vasya", "6666", "Менеджер", "vas");
            managers.dataManagers.Rows.Add("3", "Egor", "3333", "Менеджер", "egor");

            ManagerTypeCol coll = new ManagerTypeCol();
            ManagerFactory fact = new ManagerFactory();
            int            a    = ManagerFactory.count();

            ManagerFactory.AddNewManager(manager);
            Assert.AreEqual(a + 1, ManagerFactory.count());
        }
        public User Login(UserLogin userLogin)
        {
            users u = context.users.FirstOrDefault(x => x.userName == userLogin.userName && x.password == userLogin.password);

            if (u == null)
            {
                return(null);
            }

            //busco en la tabla de customers por si es un customer
            customers c = context.customers.FirstOrDefault(x => x.userId == u.id);

            if (c != null)
            {
                return(new User(u, CONSTANTES.USER_TYPE_CUSTOMER));
            }
            //busco en la tabla de employees por si es un employee
            employees e = context.employees.FirstOrDefault(x => x.userId == u.id);

            if (e != null)
            {
                return(new User(u, CONSTANTES.USER_TYPE_EMPLOYEE));
            }
            //busco en la tabla de managers por si es un manager
            managers m = context.managers.FirstOrDefault(x => x.userId == u.id);

            if (m != null)
            {
                return(new User(u, CONSTANTES.USER_TYPE_MANAGER));
            }
            //null si no encontró su tipo de user en las demas tablas
            return(null);
        }
Exemple #3
0
        private List <orden> allOrders(int userId)
        {
            List <orden> orderss = new List <orden>();
            //encuentro al empleado
            employees employee = context.employees.FirstOrDefault(x => x.userId == userId);
            //encuentro su manager
            managers manager = context.managers.FirstOrDefault(x => x.id == employee.managerId);
            //encuentro el bar de donde es el empleado
            bars bar = context.bars.FirstOrDefault(x => x.id == manager.barId);
            //busco las ordenes por producto de ese bar
            var pbo = context.products_by_order.Where(x => x.products.barId == bar.id).ToList();

            //busco en las ordenes
            context.orders.ToList().ForEach(x =>
            {
                pbo.ForEach(y =>
                {
                    if (x.id == y.orderId)
                    {
                        if (!orderss.Exists(z => z.id == x.id))
                        {
                            orderss.Add(new orden(x));
                        }
                    }
                });
            });
            return(orderss);
        }
Exemple #4
0
 public manager(managers m)
 {
     id    = m.id;
     email = m.email;
     barCreditCardNumber      = m.barCreditCardNumber;
     creditCardExpirationDate = m.creditCardExpirationDate;
     roleId = m.roleId;
     barId  = m.barId;
 }
Exemple #5
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());
        }
Exemple #6
0
        public void checkDelManager()
        {
            managers form = new managers();

            //add 3 records
            managers.dataManagers.Rows.Add("1", "Petya", "8888", "Менеджер", "petya");
            managers.dataManagers.Rows.Add("2", "Vasya", "6666", "Менеджер", "vas");
            managers.dataManagers.Rows.Add("3", "Egor", "3333", "Менеджер", "egor");

            ManagerTypeCol coll = new ManagerTypeCol();
            ManagerFactory fact = new ManagerFactory();
            int            a    = ManagerFactory.count();

            ManagerFactory.DeleteManager(1);
            Assert.AreEqual(a - 1, ManagerFactory.count());
        }
Exemple #7
0
        public void checkAddOrder()
        {
            string[] order = new string[5];
            order[0] = "225";
            order[1] = "Petr";
            order[2] = "Vasya";
            order[3] = "12 may 2013";
            order[4] = "goods";

            Clients formCL = new Clients();

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

            managers formMan = new managers();

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

            OrdersForm formOrd = new OrdersForm();

            OrdersForm.dataOrders.Rows.Add("Pet", "Petya", "12 may 2015", "1", "Goods1");
            OrdersForm.dataOrders.Rows.Add("Pet", "Petya", "13 may 2014", "2", "Goods2");
            OrdersForm.dataOrders.Rows.Add("Pet", "Petya", "14 may 2014", "3", "Goods3");

            TypeGoodsForm type = new TypeGoodsForm();

            TypeGoodsForm.dataTypeGoods.Rows.Add("1", "Саморез");
            TypeGoodsCol obj = new TypeGoodsCol();

            GoodsTypeCol goodstype = new GoodsTypeCol();

            GoodsForm formGoods = new GoodsForm();

            GoodsForm.dataGoods.Rows.Add("1", "goods", "type", "12000", "Рубль");
            GoodFactory  factTour = new GoodFactory();
            OrderFactory fact     = new OrderFactory();
            int          a        = OrderFactory.count();

            OrderFactory.AddOrder(order);
            Assert.AreEqual(a + 1, OrderFactory.count());
        }