Ejemplo n.º 1
0
        /// <summary>
        /// Recupere les 5 meilleurs recettes du meilleur cdr
        /// </summary>
        /// <param name="nb"></param>
        /// <returns></returns>
        private List <Recipe> GetTop5RecipesOfBestCdr(int nb = 5, bool ofWeek = false)
        {
            RecipeCreator bestCdr = GetTop5BestCDR(1, ofWeek).First(); // recupere le meilleur cdr
            DDB           ddb     = new DDB(User.DataBase, User.Username, User.Password);

            BestCDRAllTB.Text = ddb.SelectClient(new string[] { "numero" }, new string[] { $"'{bestCdr.Id}'" })[0].Name;
            List <Recipe> recipes = GetTop5Recipes(-1);                 // recupere les meilleurs recettes
            List <Recipe> top5RecipesOfBestCdr = new List <Recipe>();

            ddb.Close();

            nb = (nb == -1) ? recipes.Count() : nb;
            int cpt = 0;

            while (top5RecipesOfBestCdr.Count < nb && cpt < recipes.Count) // recupre les nb premieres
            {
                if (recipes[cpt].NumberCreator.Equals(bestCdr.Id))
                {
                    top5RecipesOfBestCdr.Add(recipes[cpt]);
                }

                cpt++;
            }

            return(top5RecipesOfBestCdr);
        }
Ejemplo n.º 2
0
        private void View()
        {
            DDB ddb = new DDB(User.DataBase, User.Username, User.Password);

            answerTextBlock.Text = ddb.SelectClient().Count().ToString();
            ddb.Close();
        }
Ejemplo n.º 3
0
        private void FillCDROfTheWeek()
        {
            RecipeCreator bestCdrOfWeek = GetTop5BestCDR(1, true).First();
            DDB           ddb           = new DDB();

            CDRWeekTB.Text = ddb.SelectClient(new string[] { "numero" }, new string[] { $"'{bestCdrOfWeek.Id}'" }).First().Name;
            ddb.Close();
        }
Ejemplo n.º 4
0
        private Client GetClient(string numberCreator)
        {
            DDB    ddb    = new DDB(User.DataBase, User.Username, User.Password);
            Client client = ddb.SelectClient(new string[] { "numero" }, new string[] { $"'{numberCreator}'" })[0];

            ddb.Close();
            return(client);
        }
Ejemplo n.º 5
0
        public void ClientSelect()
        {
            DDB ddb = new DDB(User.DataBase, User.Username, User.Password);

            List <Client> clients = ddb.SelectClient();

            ddb.Close();
            Assert.AreEqual(0, clients.Count);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Pay the creator of the recipe
        /// </summary>
        /// <param name="recipe"></param>
        private static void PayingCDR(Recipe recipe)
        {
            DDB ddB = new DDB(User.DataBase, User.Username, User.Password);

            RecipeCreator recipeCreator = ddB.SelectRecipeCreator(new string[] { "numero" }, new string[] { $"'{recipe.NumberCreator}'" })[0];
            Client        client        = ddB.SelectClient(new string[] { "numero" }, new string[] { $"'{recipeCreator.Id}'" })[0];

            client.Money += recipe.IsTrending ? 4 : 2;
            ddB.UpdateClient(client, new string[] { "nom" }, new string[] { $"'{client}'" });
            ddB.Close();
        }
Ejemplo n.º 7
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //Check if password is right

            DDB ddb = new DDB(User.DataBase, User.Username, User.Password);

            if (clientPasswordBox.Password == ddb.SelectClient(new string[] { "email" }, new string[] { $"'{this._email}'" })[0].Password)
            {
                User.ConnectedClient = ddb.SelectClient(new string[] { "email" }, new string[] { $"'{this._email}'" })[0];

                MainWindow mainWindow = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();
                if (User.ConnectedClient.UserType == Models.Enums.UserType.admin)
                {
                    mainWindow.DataContext = new Admin();
                }
                else
                {
                    mainWindow.DataContext = new MainMenu();
                }
            }
        }
Ejemplo n.º 8
0
        private void LoadCDRComboBox()
        {
            DDB                  ddb            = new DDB(User.DataBase, User.Username, User.Password);
            List <Client>        clients        = new List <Client>();
            List <RecipeCreator> recipeCreators = ddb.SelectRecipeCreator();

            foreach (RecipeCreator recipeCreator in recipeCreators)
            {
                clients.Add(ddb.SelectClient(new string[] { "numero" }, new string[] { $"'{recipeCreator.Id}'" })[0]);
            }
            if (clients.Count > 0)
            {
                cdrCB.ItemsSource   = clients;
                cdrCB.SelectedIndex = 0;
            }

            ddb.Close();
        }
Ejemplo n.º 9
0
        private void LoadCDR()
        {
            DDB ddb = new DDB(User.DataBase, User.Username, User.Password);
            List <RecipeCreator> recipeCreators = ddb.SelectRecipeCreator();

            foreach (RecipeCreator recipeCreator in recipeCreators)
            {
                string        value   = ddb.SelectClient(new string[] { "numero" }, new string[] { $"'{recipeCreator.Id}'" })[0].Name;
                List <Recipe> recipes = ddb.SelectRecipe(new string[] { "numeroCreateur" }, new string[] { $"'{recipeCreator.Id}'" });
                int           count   = 0;
                foreach (Recipe recipe in recipes)
                {
                    List <Order> orders = ddb.SelectOrder(new string[] { "nomRecette" }, new string[] { $"'{recipe.Name}'" });
                    count += orders.Count;
                }
                value += $" {count}";
                contentStackPanel.Children.Add(GetTextBlock(value, new SolidColorBrush(Colors.Green), FontWeights.Bold));
            }
            ddb.Close();
        }
Ejemplo n.º 10
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //check if email exists
            bool          isExisting = false;
            DDB           ddb        = new DDB(User.DataBase, User.Username, User.Password);
            List <Client> clients    = ddb.SelectClient(new string[] { "email" }, new string[] { $"'{EmailTextBox.Text}'" });

            if (clients != null)
            {
                if (clients.Count != 0)
                {
                    isExisting = true;
                }
            }

            if (isExisting)
            {
                this._registerOrLogin.DataContext = new Login(EmailTextBox.Text);
            }
            else
            {
                this._registerOrLogin.DataContext = new Register(EmailTextBox.Text);
            }
        }