Exemplo n.º 1
0
        public static List <Item> findItemBySearchQuery(string motCle, int categorie)
        {
            EcommerceDb db         = new EcommerceDb();
            List <Item> item       = db.Items.Where(s => s.itemName == motCle).ToList();
            Categorie   c          = db.Categories.Where(s => s.nomCategorie == motCle).FirstOrDefault();
            Categorie   c2         = db.Categories.Where(s => s.CategorieId == categorie).FirstOrDefault();
            List <Item> listFinale = null;

            if (c != null)
            {
                listFinale = item.Union(c.item.ToList()).ToList();
                if (c2 != null)
                {
                    listFinale.Union(c2.item).ToList();
                }
            }
            else if (c2 != null)
            {
                listFinale = item.Union(c2.item).ToList();
            }
            else
            {
                listFinale = item;
            }

            return(listFinale);
        }
Exemplo n.º 2
0
        public static Item findItemById(int id)
        {
            EcommerceDb ecommerceDb = new EcommerceDb();
            var         item        = ecommerceDb.Items.Where(s => s.itemId == id).FirstOrDefault();

            return(item);
        }
Exemplo n.º 3
0
        public static Client AuthentifiedClient()
        {
            EcommerceDb db = new EcommerceDb();
            int         currentClientId = Int32.Parse(System.Web.HttpContext.Current.User.Identity.Name);
            var         client          = db.Clients.Where(s => s.clientId == currentClientId).FirstOrDefault();

            return(client);
        }
Exemplo n.º 4
0
        public static Commande nouvelleCommande()
        {
            EcommerceDb db = new EcommerceDb();
            var         clientConnecter = ClientUtilitaire.FindClientParId(db, Int32.Parse(HttpContext.Current.User.Identity.Name));
            Commande    c = new Commande();

            c.Items = clientConnecter.Panier.ToList();
            return(c);
        }
Exemplo n.º 5
0
        public static Dictionary <int, string> categoryToDictionnary()//permet de creer un dropdown list pour
        {
            EcommerceDb db          = new EcommerceDb();
            var         allCategory = db.Categories.ToList();
            Dictionary <int, string> dictionnary = new Dictionary <int, string>();

            dictionnary.Add(0, "Categories");
            foreach (var category in allCategory)
            {
                dictionnary.Add(category.CategorieId, category.nomCategorie);
            }
            return(dictionnary);
        }
Exemplo n.º 6
0
        public static Client TrouverClientConnection(EcommerceDb db, Connection connection)//verifie la connection d'un client
        {
            var client = TrouverClientParEmail(db, connection.EmailAdress);

            if (client != null)
            {
                if (!(client.Password == connection.Password))
                {
                    client = null;
                }
            }
            return(client);//retour afin de determiner si on envoi message d'erreur,set cookie,etc
        }
Exemplo n.º 7
0
        public static void EditClient(EcommerceDb db, ClientEditView clientEditView)
        {
            var client = db.Clients.Where(s => s.clientId == clientEditView.clientId).FirstOrDefault();

            client.Adresse      = clientEditView.Adresse;
            client.EmailAdresse = clientEditView.EmailAdresse;
            client.Nom          = clientEditView.Nom;
            client.Password     = clientEditView.Password;
            client.Prenom       = clientEditView.Prenom;
            client.Province     = clientEditView.Province;
            client.Ville        = clientEditView.Ville;
            db.SaveChanges();
        }
Exemplo n.º 8
0
        public static Client AjouterClient(EcommerceDb db, Inscription inscription)
        {
            var client = TrouverClientParEmail(db, inscription.EmailAdresse);

            if (client == null)
            {
                client = DataManipulation.copyInscriptionToClient(inscription);
                db.Clients.Add(client);
                db.SaveChanges();
            }
            else
            {
                client = null; //on reset le client a null afin de pouvoir envoyer le  message d'errur car il existe deja dans la bd
            }
            return(client);    //retour afin de determiner si on envoi message d'erreur,set cookie,etc
        }
Exemplo n.º 9
0
        public static double panierTotalPrice(int clientId)
        {
            EcommerceDb db        = new EcommerceDb();
            var         client    = db.Clients.Where(s => s.clientId == clientId).FirstOrDefault();
            double      prixTotal = 0;

            foreach (var item in client.Panier)
            {
                int i = 0;
                do//ajuste le prix en fonction du nombre d'articles commandés
                {
                    prixTotal = prixTotal + item.itemPrice;
                    i++;
                } while (i < item.Quantite);
            }
            return(prixTotal);
        }
Exemplo n.º 10
0
        public static void AjouterItemPanier(EcommerceDb db, int clientId, int itemId, int?nombreArticle = null)
        {
            var client = db.Clients.Where(s => s.clientId == clientId).FirstOrDefault();
            var item   = db.Items.Where(s => s.itemId == itemId).FirstOrDefault();

            if (nombreArticle == null)
            {
                nombreArticle = 1;
            }
            var itemPanier = itemToItemVendu(item);

            itemPanier.Quantite = (int)nombreArticle;
            client.Panier.Add(itemPanier);
            item.quantite = (int)(item.quantite - nombreArticle);


            db.SaveChanges();
        }
Exemplo n.º 11
0
        public static List <ItemDetails> featuredInitialisation()
        {
            EcommerceDb db       = new EcommerceDb();//on cherche 3 item
            var         allItems = db.Items.ToList();

            ItemDetails[] featuredItems = new ItemDetails[3];
            int           i             = 0;//compteur

            while (true)
            {
                Random random    = new Random();
                int    radomItem = random.Next(allItems.Count());
                featuredItems[i] = DataManipulation.copyItemToItemDetails(allItems.ElementAt(radomItem));
                i = ++i;
                if (i == 3)
                {
                    break;
                }
            }
            return(featuredItems.ToList());
        }
Exemplo n.º 12
0
        public static List <Categorie> subFeaturedInitialisation()
        {
            EcommerceDb db           = new EcommerceDb();
            var         x            = db.Items.ToList();
            var         allCategorie = db.Categories.ToList();

            Categorie[] subFeaturedCategorie = new Categorie[3];
            int         i = 0;

            while (true)
            {
                Random random          = new Random();
                int    randomCategorie = random.Next(allCategorie.Count());
                var    categorieEnvoye = allCategorie.ElementAt(randomCategorie);
                subFeaturedCategorie[i] = allCategorie.ElementAt(randomCategorie);
                Item[] subFeaturedCategoryItem = new Item[4];
                int    i2 = 0;
                while (true)
                {
                    int randomItem = random.Next(categorieEnvoye.item.Count());
                    var item       = categorieEnvoye.item.ElementAt(randomItem);
                    subFeaturedCategoryItem[i2] = item;

                    i2 = ++i2;
                    if (i2 == 4)
                    {
                        break;
                    }
                }
                categorieEnvoye.item    = subFeaturedCategoryItem.ToList();
                subFeaturedCategorie[i] = categorieEnvoye;
                i = ++i;
                if (i == 3)
                {
                    break;
                }
            }

            return(subFeaturedCategorie.ToList());
        }
Exemplo n.º 13
0
        public static List <Categorie> ItemDisplayInitialisation()
        {
            EcommerceDb db           = new EcommerceDb();
            var         x            = db.Items.ToList();
            var         allCategorie = db.Categories.ToList();

            Categorie[] subFeaturedCategorie = new Categorie[5];
            int         i = 0;

            while (true)
            {
                Random random          = new Random();
                int    randomCategorie = random.Next(allCategorie.Count());
                var    categorieEnvoye = allCategorie.ElementAt(randomCategorie);
                subFeaturedCategorie[i] = allCategorie.ElementAt(randomCategorie);
                subFeaturedCategorie[i] = categorieEnvoye;
                i = ++i;
                if (i == subFeaturedCategorie.Length)
                {
                    break;
                }
            }
            return(subFeaturedCategorie.ToList());
        }
Exemplo n.º 14
0
        public static void ConfirmerCommande(Commande commande, string CardNumber, string MoisExpiration, string AnneExpiration, string Cvv)
        {
            EcommerceDb db = new EcommerceDb();


            commande.dateCommande = DateTime.Now;
            commande.Client       = ClientUtilitaire.FindClientParId(db, Int32.Parse(HttpContext.Current.User.Identity.Name));
            commande.Items        = commande.Client.Panier.ToList();
            foreach (var i in commande.Items)
            {
                int compt = 0;
                do
                {
                    commande.MontantCommande = i.itemPrice;
                    compt = ++compt;
                } while (compt < i.Quantite);
            }

            CreditCard creditCard = new CreditCard();

            creditCard.CardNumber     = Int64.Parse(CardNumber);                                                   //changer cardnumber en long
            creditCard.Cvv            = Int32.Parse(Cvv);
            creditCard.DateExpiration = new DateTime(Int32.Parse(AnneExpiration), Int32.Parse(MoisExpiration), 1); //sa expire le premierdu mois donc le dernier argument est 1

            commande.CreditCard = creditCard;

            db.CreditCards.Add(creditCard);
            db.Commande.Add(commande);

            //db.Commande.Add(new Commande());
            var didi = db.Commande.ToList();

            commande.Client.Panier = null;

            db.SaveChanges();
        }
Exemplo n.º 15
0
 public CartsDb(EcommerceDb db)
 {
     _db = db;
 }
Exemplo n.º 16
0
 public static void DeleteClient(EcommerceDb db, int id)
 {
     db.Clients.Remove(FindClientParId(db, id));
     db.SaveChanges();
 }
Exemplo n.º 17
0
 public static Client FindClientParId(EcommerceDb db, int id)
 {
     return(db.Clients.Where(s => s.clientId == id).FirstOrDefault());
 }
Exemplo n.º 18
0
        public static Client TrouverClientParEmail(EcommerceDb db, string emailAdresse)
        {
            var client = db.Clients.Where(s => s.EmailAdresse == emailAdresse).FirstOrDefault();

            return(client);//retourne client afin de set le cookie
        }
Exemplo n.º 19
0
 public CommandeController()
 {
     db = new EcommerceDb();
 }
Exemplo n.º 20
0
 public Productsdb(EcommerceDb db)
 {
     _db = db;
 }
Exemplo n.º 21
0
 public ItemController()
 {
     db = new EcommerceDb();
 }
Exemplo n.º 22
0
 public BaseRepository()
 {
     _db = new EcommerceDb();
 }
Exemplo n.º 23
0
 public OrdersDb(EcommerceDb db)
 {
     _db = db;
 }
Exemplo n.º 24
0
 public ClientController()
 {
     db = new EcommerceDb();
 }
Exemplo n.º 25
0
 public static Categorie findCategorieByiD(EcommerceDb db, int id)
 {
     return(db.Categories.Where(s => s.CategorieId == id).FirstOrDefault());
 }