Exemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
0
 public bool Commit()
 {
     return(_db.SaveChanges() > 0);
 }
Exemplo n.º 6
0
 public static void DeleteClient(EcommerceDb db, int id)
 {
     db.Clients.Remove(FindClientParId(db, id));
     db.SaveChanges();
 }