Exemple #1
0
        public bool InsertObjToDB <T>(object o)
        {
            AspDbContext context = new AspDbContextFactory().CreateDbContext(null);
            string       query;

            switch (typeof(T).Name)
            {
            case ("Evenement"):
                Evenement e = o as Evenement;
                query = string.Format("INSERT INTO dbo.Evenement (Adresse,Cp,DateHeureCreation,DateHeureEvenement,Description,OrganisateurIdOrga,Tags,Titre,Ville) values ('{0}','{1}','{2}','{3}','{4}',{5},'{6}','{7}','{8}')", e.Adresse, e.Cp, e.DateHeureCreation.ToString().Substring(0, 10), e.DateHeureEvenement.ToString().Substring(0, 10), e.Description, 1, e.Tags, e.Titre, e.Ville);
                context.Database.ExecuteSqlCommand(query);
                break;

            case ("Organisateur"):
                Organisateur or = o as Organisateur;
                query = string.Format("INSERT INTO dbo.Organisateur (Login, Nom, Prenom, Email, Tel, Port, DateInscription, NomOrganisation, EvenementsOrganises) VALUE ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}')", or.Login, or.Nom, or.Prenom, or.Email, or.Tel, or.Port, or.DateInscription.ToString().Substring(0, 10), or.NomOrganisation, or.EvenementsOrganises);
                context.Database.ExecuteSqlCommand(query);
                break;

            case ("Visiteur"):
                break;
            }
            if (context.SaveChanges() == -1)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemple #2
0
        public static void EnoyerEvenement(Evenement e)
        {
            AspDbContext context = new AspDbContextFactory().CreateDbContext(null);
            var          test    = context.Add(e);

            context.SaveChanges();
        }
Exemple #3
0
        public static Evenement ModifEvent(Evenement e)
        {
            AspDbContext context = new AspDbContextFactory().CreateDbContext(null);

            context.Update(e);
            context.SaveChanges();
            return(e);
        }
Exemple #4
0
        public object ModifObjToDB(object o)
        {
            AspDbContext context = new AspDbContextFactory().CreateDbContext(null);
            var          test    = context.Update(o);

            if (context.SaveChanges() == -1)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemple #5
0
        public static List <Visisteur> GetVisits()
        {
            AspDbContext context = new AspDbContextFactory().CreateDbContext(null);

            return(context.Visisteurs.ToList());
        }
        public static List <Organisateur> GetOrgas()
        {
            AspDbContext context = new AspDbContextFactory().CreateDbContext(null);

            return(context.Organisateurs.ToList());
        }
Exemple #7
0
        public static List <Evenement> GetEvents()
        {
            AspDbContext context = new AspDbContextFactory().CreateDbContext(null);

            return(context.Evenements.ToList());
        }