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()); } }
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); } } }
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(); } } }
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); } } }
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(); } } }
private OuvertureHebdomadaire ProchainOuvertHabituellement(DateTime date) { using (foodtruckEntities db = new foodtruckEntities()) { TimeSpan minuit = new TimeSpan(0, 0, 0); int totalSecondesDate = 24 * 60 * 60 * (int)date.DayOfWeek + (int)date.TimeOfDay.TotalSeconds; OuvertureHebdomadaire plage = (from ouverture in db.OuvertureHebdomadaire let totalSecondesOuverture = 24 * 60 * 60 * ouverture.JourSemaineId + DbFunctions.DiffSeconds(minuit, ouverture.Fin) where totalSecondesOuverture > totalSecondesDate orderby totalSecondesOuverture select ouverture).FirstOrDefault(); DateTime maintenant = DateTime.Now; if (plage == null) { plage = (from c in db.OuvertureHebdomadaire orderby c.JourSemaineId, c.Debut select c).First(); } else if (date.Date == maintenant.Date && plage.JourSemaineId == (int)maintenant.DayOfWeek && plage.Debut < maintenant.TimeOfDay) { plage.Debut = RecalculHeureDebut(date); } return(plage); } }
internal int NombreCommandes(DateTime date) { using (foodtruckEntities db = new foodtruckEntities()) { int nbCommandes = (from cmd in db.Commande where cmd.DateRetrait == date && !cmd.Annulation && !cmd.Retrait select cmd.Id).Count(); return(nbCommandes); } }
public List <Client> Recherche(string recherche) { using (foodtruckEntities db = new foodtruckEntities()) { List <Client> clients = (from c in db.Client where c.Id != 0 && (c.Nom.Contains(recherche) || c.Prenom.Contains(recherche) || c.Email.Contains(recherche) || c.Telephone.Contains(recherche)) select c).ToList(); return(clients); } }
internal List <OuvertureHebdomadaire> OuverturesHebdomadaires() { using (foodtruckEntities db = new foodtruckEntities()) { List <OuvertureHebdomadaire> ouvertures = (from p in db.OuvertureHebdomadaire orderby p.JourSemaineId, p.Debut select p).ToList(); return(ouvertures); } }
internal Commande Detail(int id) { using (foodtruckEntities db = new foodtruckEntities()) { Commande commande = (from cmd in db.Commande where cmd.Id == id select cmd).FirstOrDefault(); return(commande); } }
internal CodePromo Detail(string code) { using (foodtruckEntities db = new foodtruckEntities()) { CodePromo codePromo = (from cp in db.CodePromo where cp.Code == code select cp).FirstOrDefault(); return(codePromo); } }
public List <Commande> CommandesEnCours(int fourchetteHeures) { using (foodtruckEntities db = new foodtruckEntities()) { var commandes = (from cmd in db.Commande where !cmd.Retrait && !cmd.Annulation && Math.Abs((int)DbFunctions.DiffHours(DateTime.Now, cmd.DateRetrait)) < Math.Abs(fourchetteHeures) orderby cmd.DateRetrait select cmd).ToList(); return(commandes); } }
public List <Article> ArticlesPanierProspect() { using (foodtruckEntities db = new foodtruckEntities()) { List <Article> articles = (from panier in db.PanierProspect join article in db.Article on panier.ArticleId equals article.Id where panier.ProspectGuid == ProspectGuid select article).ToList(); return(articles); } }
public Facture Details(string guid) { using (foodtruckEntities db = new foodtruckEntities()) { Facture facture = (from f in db.Facture where f.Guid == guid select f).FirstOrDefault(); return(facture); } }
internal CreerAdmin Details(string identifiant) { using (foodtruckEntities db = new foodtruckEntities()) { DateTime maintenant = DateTime.Now; var creerAdmin = (from u in db.CreerAdmin where u.CodeVerification == identifiant && DbFunctions.DiffMinutes(maintenant, u.DateFinValidite) >= 0 select u).FirstOrDefault(); return(creerAdmin); } }
public Client Details(int id) { using (foodtruckEntities db = new foodtruckEntities()) { Client client = (from c in db.Client where c.Id == id select c).FirstOrDefault(); Trim(ref client); return(client); } }
public int ExisteEmail(string email) { using (foodtruckEntities db = new foodtruckEntities()) { int clientId = (from c in db.Client where c.Email == email select c.Id).FirstOrDefault(); return(clientId); } }
public int ExisteLogin(string login) { using (foodtruckEntities db = new foodtruckEntities()) { int clientId = (from c in db.Client where c.Login == login select c.Id).FirstOrDefault(); return(clientId); } }
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(); } }
public List <Panier> ListerPanierClient() { using (foodtruckEntities db = new foodtruckEntities()) { List <Panier> paniers = (from panier in db.Panier join article in db.Article on panier.ArticleId equals article.Id where panier.ClientId == ClientId select panier).ToList(); return(paniers); } }
public List <Article> ArticlesPanierClient() { using (foodtruckEntities db = new foodtruckEntities()) { List <Article> articles = (from panier in db.Panier join article in db.Article on panier.ArticleId equals article.Id where panier.ClientId == ClientId select article).ToList(); return(articles); } }
internal List <Commande> CommandesClient(int id, int max = int.MaxValue) { using (foodtruckEntities db = new foodtruckEntities()) { List <Commande> commandes = (from cmd in db.Commande where cmd.ClientId == id orderby cmd.Annulation, cmd.Retrait, Math.Abs((int)DbFunctions.DiffHours(DateTime.Now, cmd.DateRetrait)) select cmd).Take(max).ToList(); return(commandes); } }
public Client ConnexionCookies(string guid) { using (foodtruckEntities db = new foodtruckEntities()) { Client client = (from c in db.Client where c.Guid == guid select c).FirstOrDefault(); Trim(ref client); return(client); } }
public Client Details(string email) { using (foodtruckEntities db = new foodtruckEntities()) { Client client = (from c in db.Client where c.Email == email select c).FirstOrDefault(); Trim(ref client); return(client); } }
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()); } }
internal OubliMotDePasse Details(string identifiant) { using (foodtruckEntities db = new foodtruckEntities()) { DateTime maintenant = DateTime.Now; var oubliMotDePasse = (from u in db.OubliMotDePasse where u.CodeVerification == identifiant && DbFunctions.DiffMinutes(maintenant, u.DateFinValidite) >= 0 select u).FirstOrDefault(); return(oubliMotDePasse); } }
public Tva Details(int id) { using (foodtruckEntities db = new foodtruckEntities()) { Tva tva = (from t in db.Tva where t.Id == id select t).FirstOrDefault(); return(tva); } }
public float Taux(int id) { using (foodtruckEntities db = new foodtruckEntities()) { double taux = (from t in db.Tva where t.Id == id select t.Taux).FirstOrDefault(); return((float)Math.Round(taux, 1)); } }
public float TauxFamilleArticle(int familleArticleId) { using (foodtruckEntities db = new foodtruckEntities()) { var taux = (from t in db.Tva join f in db.FamilleArticle on t.Id equals f.TvaId where f.Id == familleArticleId select t.Taux).FirstOrDefault(); return((float)Math.Round(taux, 1)); } }
internal List <Commande> CommandesEnCoursClient(int id) { using (foodtruckEntities db = new foodtruckEntities()) { DateTime now = DateTime.Now; List <Commande> commandes = (from cmd in db.Commande where cmd.ClientId == id && !cmd.Annulation && !cmd.Retrait && DbFunctions.DiffHours(now, cmd.DateRetrait) > -1 orderby Math.Abs((int)DbFunctions.DiffMinutes(now, cmd.DateRetrait)) select cmd).ToList(); return(commandes); } }