Пример #1
0
        internal int Modification(int id, string mdp, string login = null, string email = null, string nom = null, string prenom = null, string telephone = null)
        {
            using (foodtruckEntities db = new foodtruckEntities())
            {
                Client client = (from user in db.Client
                                 where user.Id == id
                                 select user).FirstOrDefault();

                client.Mdp = mdp.GetHash();
                if (email != null)
                {
                    client.Email = email.Trim();
                }
                if (login != null)
                {
                    client.Login = login.Trim();
                }
                if (nom != null)
                {
                    client.Nom = nom.Trim();
                }
                if (prenom != null)
                {
                    client.Prenom = prenom.Trim();
                }
                if (telephone != null)
                {
                    client.Telephone = telephone.Trim();
                }
                return(db.SaveChanges());
            }
        }
Пример #2
0
        internal void Modifier(Article article)
        {
            using (foodtruckEntities db = new foodtruckEntities())
            {
                Article articleAModifier = (from art in db.Article
                                            where art.Id == article.Id
                                            select art).FirstOrDefault();

                articleAModifier.Nom         = article.Nom;
                articleAModifier.Description = article.Description;
                articleAModifier.PrixTTC     = article.PrixTTC;
                articleAModifier.Allergenes  = article.Allergenes;
                articleAModifier.DansCarte   = article.DansCarte;
                articleAModifier.FamilleId   = article.FamilleId;
                articleAModifier.Grammage    = article.Grammage;
                articleAModifier.Litrage     = article.Litrage;
                articleAModifier.Image       = article.Image;
                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    string messageErreur = DALExceptions.HandleException(ex);
                    throw new Exception(messageErreur);
                }
            }
        }
Пример #3
0
 public Client Creation(string email, string login, string mdp, string nom, string prenom, string telephone)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         string mdpHash = mdp.GetHash();
         string guid    = Guid.NewGuid().ToString();
         int    id      = (from c in db.Client
                           where c.Email == email || c.Guid == guid
                           select c.Id).FirstOrDefault();
         if (id == 0)
         {
             Client client = new Client
             {
                 Guid        = guid,
                 Email       = email.Trim(),
                 Login       = login.Trim(),
                 Mdp         = mdpHash,
                 Nom         = nom.Trim(),
                 Prenom      = prenom.Trim(),
                 Telephone   = telephone.Trim(),
                 Cagnotte    = 0,
                 Inscription = DateTime.Today
             };
             db.Client.Add(client);
             db.SaveChanges();
             return(Connexion(email, mdp));
         }
         else
         {
             return(null);
         }
     }
 }
Пример #4
0
        public static void Enregistrer(int clientId)
        {
            string adresseIP     = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            string ipsNonTracees = ConfigurationManager.AppSettings["ListIpDoNotTrack"];

            string[] tabIpsNonTracees = ipsNonTracees.Split(';');
            if (!tabIpsNonTracees.Any(ip => adresseIP == ip))
            {
                string url        = System.Web.HttpContext.Current.Request.Url.ToString();
                string navigateur = System.Web.HttpContext.Current.Request.Browser.Browser;
                string UrlOrigine = "";
                if (System.Web.HttpContext.Current.Request.UrlReferrer != null)
                {
                    UrlOrigine = System.Web.HttpContext.Current.Request.UrlReferrer.ToString();
                }
                Visite visite = new Visite
                {
                    Url              = url,
                    Date             = DateTime.Now,
                    AdresseIp        = adresseIP,
                    ClientId         = clientId,
                    Navigateur       = navigateur,
                    UrlOrigine       = UrlOrigine,
                    NavigateurMobile = Utilitaire.NavigateurMobile(),
                };
                using (foodtruckEntities db = new foodtruckEntities())
                {
                    db.Visite.Add(visite);
                    db.SaveChanges();
                }
            }
        }
Пример #5
0
 private void MettreAJourStatut(int id, bool retrait, bool annule)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         Commande commande = (from cmd in db.Commande
                              where cmd.Id == id
                              select cmd).FirstOrDefault();
         if (commande != null)
         {
             commande.Annulation = annule;
             commande.Retrait    = retrait;
             Client client = (from u in db.Client
                              where u.Id == commande.ClientId
                              select u).FirstOrDefault();
             if (commande.Retrait)
             {
                 client.Cagnotte += (int)commande.PrixTotalTTC / 10;
             }
             if (commande.Annulation)
             {
                 client.Cagnotte += (int)commande.RemiseFidelite;
             }
             db.SaveChanges();
         }
     }
 }
 public int Purger()
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         IQueryable <JourExceptionnel> joursExceptionnels = from j in db.JourExceptionnel
                                                            where DbFunctions.DiffMinutes(j.DateFin, DateTime.Now) > 0
                                                            select j;
         db.JourExceptionnel.RemoveRange(joursExceptionnels);
         return(db.SaveChanges());
     }
 }
Пример #7
0
 internal void AugmenterQuantiteVendue(int id, int nbre)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         Article article = (from a in db.Article
                            where a.Id == id
                            select a).FirstOrDefault();
         article.NombreVendus += nbre;
         db.SaveChanges();
     }
 }
Пример #8
0
        /// Supprimer le panier en base du client
        public void Supprimer()
        {
            using (foodtruckEntities db = new foodtruckEntities())
            {
                var panierProspect = from panier in db.PanierProspect
                                     where panier.ProspectGuid == ProspectGuid
                                     select panier;

                db.PanierProspect.RemoveRange(panierProspect);
                db.SaveChanges();
            }
        }
Пример #9
0
        /// Supprimer l'article du panier en base du client
        public void Supprimer(Article lArticle)
        {
            using (foodtruckEntities db = new foodtruckEntities())
            {
                PanierProspect panierProspect = (from panier in db.PanierProspect
                                                 where panier.ProspectGuid == ProspectGuid && panier.ArticleId == lArticle.Id
                                                 select panier).FirstOrDefault();

                db.PanierProspect.Remove(panierProspect);
                db.SaveChanges();
            }
        }
Пример #10
0
 internal void Supprimer(string email)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         List <CreerAdmin> listeAdminTemporaire =
             (from a in db.CreerAdmin
              where a.Email == email
              select a).ToList();
         db.CreerAdmin.RemoveRange(listeAdminTemporaire);
         db.SaveChanges();
     }
 }
Пример #11
0
        public int Purger()
        {
            using (foodtruckEntities db = new foodtruckEntities())
            {
                IQueryable <OubliMotDePasse> listeOubliMotDePasse = from u in db.OubliMotDePasse
                                                                    where DbFunctions.DiffMinutes(u.DateFinValidite, DateTime.Now) > 0
                                                                    select u;

                db.OubliMotDePasse.RemoveRange(listeOubliMotDePasse);
                return(db.SaveChanges());
            }
        }
Пример #12
0
 ///Modifier la quantité d'un article du panier en base d'un client
 public void ModifierQuantite(Article article, int quantite)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         Panier panier = (from p in db.Panier
                          where p.ClientId == ClientId && p.ArticleId == article.Id
                          select p).FirstOrDefault();
         panier.Quantite += quantite;
         panier.PrixTotal = Math.Round(panier.PrixTotal + quantite * article.PrixTTC, 2);
         db.SaveChanges();
     }
 }
Пример #13
0
        /// Supprimer le panier en base du client
        public void Supprimer()
        {
            using (foodtruckEntities db = new foodtruckEntities())
            {
                var panier = from p in db.Panier
                             where p.ClientId == ClientId
                             select p;

                db.Panier.RemoveRange(panier);
                db.SaveChanges();
            }
        }
Пример #14
0
        /// Supprimer l'article du panier en base de du client
        public void Supprimer(Article article)
        {
            using (foodtruckEntities db = new foodtruckEntities())
            {
                Panier panier = (from p in db.Panier
                                 where p.ClientId == ClientId && p.ArticleId == article.Id
                                 select p).FirstOrDefault();

                db.Panier.Remove(panier);
                db.SaveChanges();
            }
        }
Пример #15
0
 internal void Supprimer(int clientId)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         List <OubliMotDePasse> listeOubliMotDePasse =
             (from u in db.OubliMotDePasse
              where u.ClientId == clientId
              select u).ToList();
         db.OubliMotDePasse.RemoveRange(listeOubliMotDePasse);
         db.SaveChanges();
     }
 }
Пример #16
0
        internal int DonnerDroitAdmin(int id)
        {
            using (foodtruckEntities db = new foodtruckEntities())
            {
                Client client = (from user in db.Client
                                 where user.Id == id
                                 select user).FirstOrDefault();

                client.AdminArticle = client.AdminCommande = client.AdminPlanning = true;
                return(db.SaveChanges());
            }
        }
Пример #17
0
 ///Modifier la quantité d'un article du panier en base d'un client
 public void ModifierQuantite(Article lArticle, int quantite)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         PanierProspect panierProspect = (from panier in db.PanierProspect
                                          where panier.ProspectGuid == ProspectGuid && panier.ArticleId == lArticle.Id
                                          select panier).FirstOrDefault();
         panierProspect.Quantite += quantite;
         panierProspect.PrixTotal = Math.Round(panierProspect.PrixTotal + quantite * lArticle.PrixTTC, 2);
         panierProspect.DateAjout = DateTime.Now;
         db.SaveChanges();
     }
 }
Пример #18
0
 public void Ajouter(Commande commande, List <ArticleViewModel> articlesVM)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         db.Commande.Add(commande);
         db.SaveChanges();
         int commandeId = (from cmd in db.Commande
                           where cmd.ClientId == commande.ClientId
                           orderby cmd.Id descending
                           select cmd.Id).FirstOrDefault();
         double remiseTotalCommandeHT = 0;
         double totalCommandeHT       = 0;
         foreach (var articleVM in articlesVM)
         {
             float  tauxTva             = new TvaDAL().TauxArticle(articleVM.Article.Id);
             int    quantite            = articleVM.Quantite;
             double prixTotalTTC        = articleVM.Article.PrixTTC * quantite;
             double prixTotalHT         = prixTotalTTC * 100 / (100 + tauxTva);
             double fractionPrixArticle = prixTotalTTC / (commande.PrixTotalTTC + commande.RemiseCommerciale + commande.RemiseFidelite);
             double remiseArticleTTC    = fractionPrixArticle * (commande.RemiseCommerciale + commande.RemiseFidelite);
             double remiseArticleHT     = remiseArticleTTC * prixTotalHT / prixTotalTTC;
             remiseTotalCommandeHT += remiseArticleHT;
             totalCommandeHT       += prixTotalHT;
             Commande_Article cmdArt = new Commande_Article
             {
                 CommandeId   = commandeId,
                 ArticleId    = articleVM.Article.Id,
                 Quantite     = quantite,
                 PrixTotalTTC = Math.Round(prixTotalTTC, 2),
                 PrixTotalHT  = Math.Round(prixTotalHT, 2)
             };
             db.Commande_Article.Add(cmdArt);
         }
         commande.PrixTotalHT = Math.Round(totalCommandeHT - remiseTotalCommandeHT, 2);
         db.SaveChanges();
     }
 }
Пример #19
0
 internal void Ajouter(int clientId, string codeVerification, DateTime dateFinValidite)
 {
     Supprimer(clientId);
     using (foodtruckEntities db = new foodtruckEntities())
     {
         OubliMotDePasse oubliMotDePasse = new OubliMotDePasse
         {
             ClientId         = clientId,
             CodeVerification = codeVerification,
             DateFinValidite  = dateFinValidite
         };
         db.OubliMotDePasse.Add(oubliMotDePasse);
         db.SaveChanges();
     }
 }
Пример #20
0
        ///Ajouter un article non présent au panier en base d'un client
        public void Ajouter(Article article, int quantite = 1)
        {
            Panier lePanier = new Panier
            {
                ArticleId = article.Id,
                ClientId  = ClientId,
                Quantite  = quantite,
                PrixTotal = Math.Round(quantite * article.PrixTTC, 2)
            };

            using (foodtruckEntities db = new foodtruckEntities())
            {
                db.Panier.Add(lePanier);
                db.SaveChanges();
            }
        }
Пример #21
0
 /// <summary>
 /// Ajoute l'article lArticle en base
 /// </summary>
 /// <param name="article"></param>
 internal void Ajouter(Article article)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         db.Article.Add(article);
         try
         {
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             string messageErreur = DALExceptions.HandleException(ex);
             throw new Exception(messageErreur);
         }
     }
 }
Пример #22
0
        /// <summary>
        /// Purge les entrées de la table PanierProspect dont le prospect à ajouter à son panier un article depuis plus de ageEnJours jours
        /// </summary>
        /// <param name="ageEnJours"></param>
        /// <returns></returns>
        public int Purger(int ageEnJours)
        {
            using (foodtruckEntities db = new foodtruckEntities())
            {
                IQueryable <string> GuidsAGarder = (from panier in db.PanierProspect
                                                    where DbFunctions.DiffDays(panier.DateAjout, DateTime.Today) < ageEnJours
                                                    select panier.ProspectGuid).Distinct();

                List <PanierProspect> paniersAPurger = (from panier in db.PanierProspect
                                                        where !GuidsAGarder.Any(guid => panier.ProspectGuid.Contains(guid))
                                                        select panier).ToList();

                db.PanierProspect.RemoveRange(paniersAPurger);
                return(db.SaveChanges());
            }
        }
Пример #23
0
 internal void Ajouter(Client client, string codeVerification, DateTime dateFinValidite)
 {
     Supprimer(client.Email);
     using (foodtruckEntities db = new foodtruckEntities())
     {
         CreerAdmin creerAdmin = new CreerAdmin
         {
             Email            = client.Email,
             Nom              = client.Nom,
             Prenom           = client.Prenom,
             CodeVerification = codeVerification,
             DateFinValidite  = dateFinValidite
         };
         db.CreerAdmin.Add(creerAdmin);
         db.SaveChanges();
     }
 }
Пример #24
0
        ///Ajouter un article non présent au panier en base d'un prospect
        public void Ajouter(Article lArticle, int quantite = 1)
        {
            PanierProspect panierProspect = new PanierProspect
            {
                ArticleId    = lArticle.Id,
                ProspectGuid = this.ProspectGuid,
                Quantite     = quantite,
                PrixTotal    = Math.Round(quantite * lArticle.PrixTTC, 2),
                DateAjout    = DateTime.Now,
            };

            using (foodtruckEntities db = new foodtruckEntities())
            {
                db.PanierProspect.Add(panierProspect);
                db.SaveChanges();
            }
        }
Пример #25
0
        internal List <Article> SupprimerArticlesPasDansCarte()
        {
            List <Article> articles             = ArticlesPanierClient();
            List <Article> articlesPasDansCarte = articles.FindAll(art => !art.DansCarte);

            using (foodtruckEntities db = new foodtruckEntities())
            {
                var paniersASupprimer = (from panier in db.Panier
                                         join article in db.Article on panier.ArticleId equals article.Id
                                         where panier.ClientId == ClientId && !article.DansCarte
                                         select panier).ToList();

                db.Panier.RemoveRange(paniersASupprimer);
                db.SaveChanges();
            }
            return(articlesPasDansCarte);
        }
Пример #26
0
 internal bool SupprimerOuverture(int id)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         OuvertureHebdomadaire ouverture = (from p in db.OuvertureHebdomadaire
                                            where p.Id == id
                                            select p).FirstOrDefault();
         db.OuvertureHebdomadaire.Remove(ouverture);
         if (db.SaveChanges() != 1)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
Пример #27
0
 /// <summary>
 /// Si le solde est suffisant, retire "montant" euros de la cagnotte de client d'id "id" et retourne le solde restant
 /// Si le solde de la cagnotte est insuffisant retourne -1 sans rien modifier
 /// </summary>
 /// <param name="id"></param>
 /// <param name="montant"></param>
 /// <returns></returns>
 internal int RetirerCagnotte(int id, int montant)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         var client = (from c in db.Client
                       where c.Id == id
                       select c).FirstOrDefault();
         if (montant <= client.Cagnotte)
         {
             client.Cagnotte -= montant;
             db.SaveChanges();
             return(client.Cagnotte);
         }
         else
         {
             return(-1);
         }
     }
 }
        private bool SupprimerPeriodeExceptionnelle(DateTime dateId, bool ouvert)
        {
            using (foodtruckEntities db = new foodtruckEntities())
            {
                JourExceptionnel jourSelectionne = (from j in db.JourExceptionnel
                                                    where j.DateDebut == dateId && j.Ouvert == ouvert
                                                    select j).FirstOrDefault();

                db.JourExceptionnel.Remove(jourSelectionne);
                if (db.SaveChanges() != 1)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
Пример #29
0
 public Facture DetailsCommande(int id)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         Facture facture = (from f in db.Facture
                            where f.CommandeId == id
                            select f).FirstOrDefault();
         if (facture == null)
         {
             facture = new Facture
             {
                 CommandeId = id,
                 Guid       = Guid.NewGuid().ToString("n"),
             };
             db.Facture.Add(facture);
             db.SaveChanges();
         }
         return(facture);
     }
 }
 private JourExceptionnel AjouterPeriodeExceptionnelle(DateTime dateDebut, DateTime dateFin, bool ouvert)
 {
     using (foodtruckEntities db = new foodtruckEntities())
     {
         JourExceptionnel chevauchement = (from j in db.JourExceptionnel
                                           where DbFunctions.DiffMinutes(j.DateDebut, dateFin) >= 0 && DbFunctions.DiffMinutes(dateDebut, j.DateFin) >= 0
                                           select j).FirstOrDefault();
         if (chevauchement == null)
         {
             JourExceptionnel jour = new JourExceptionnel
             {
                 DateDebut = dateDebut,
                 DateFin   = dateFin,
                 Ouvert    = ouvert,
             };
             db.JourExceptionnel.Add(jour);
             db.SaveChanges();
         }
         return(chevauchement);
     }
 }