Esempio n. 1
0
        private static void ModifierTechnologies(GDA_Context context, ComposantModel composantModif)
        {
            var technologies = context.ComposantTechnologies.Where(x => x.ComposantId == composantModif.Id);

            context.ComposantTechnologies.DeleteAllOnSubmit(technologies);

            //New technologies
            if (composantModif.Technologies.Any(x => x.Id == 0))
            {
                var nouvellesTechnologies = composantModif.Technologies.Where(x => x.Id == 0).Select(x => new Technologie
                {
                    Nom = x.Nom
                }).ToList();

                TechnologieBL.CreerTechnologies(nouvellesTechnologies);

                context.ComposantTechnologies.InsertAllOnSubmit(nouvellesTechnologies.Select(x => new ComposantTechnologie
                {
                    TechnologieId = x.Id,
                    ComposantId   = composantModif.Id
                }));
            }

            //Existing technologies
            context.ComposantTechnologies.InsertAllOnSubmit(composantModif.Technologies.Where(x => x.Id != 0).Select(x => new ComposantTechnologie
            {
                TechnologieId = x.Id,
                ComposantId   = composantModif.Id
            }));

            context.SubmitChanges();
        }
Esempio n. 2
0
        public static void CreerComposant(ComposantModel nouveauComposant)
        {
            using (GDA_Context context = new GDA_Context())
            {
                var composant = new Composant
                {
                    Nom               = nouveauComposant.Nom,
                    Abreviation       = nouveauComposant.Abreviation,
                    Version           = nouveauComposant.Version,
                    Description       = nouveauComposant.Description,
                    ComposantTypeId   = nouveauComposant.Type.Id,
                    NomBD             = nouveauComposant.NomBD,
                    SourceControlPath = nouveauComposant.SourceControlPath,
                    BC          = nouveauComposant.BC,
                    BW          = nouveauComposant.BW,
                    DerniereMAJ = DateTime.Now
                };

                context.Composants.InsertOnSubmit(composant);

                context.SubmitChanges();

                nouveauComposant.Id = composant.Id;             //Set the newly inserted id

                CreerEnvironnements(context, nouveauComposant); //This call has to be made before adding dependencies
                ModifierClients(context, nouveauComposant);
                ModifierResponsables(context, nouveauComposant);
                ModifierTechnologies(context, nouveauComposant);
                ModifierDependances(context, nouveauComposant);
            }
        }
Esempio n. 3
0
        private static void ModifierClients(GDA_Context context, ComposantModel composantModif)
        {
            var clients = context.ComposantClients.Where(x => x.ComposantId == composantModif.Id);

            context.ComposantClients.DeleteAllOnSubmit(clients);

            //New clients
            if (composantModif.Clients.Any(x => x.Id == 0))
            {
                var nouveauxClients = composantModif.Clients.Where(x => x.Id == 0).Select(x => new Client
                {
                    Nom = x.Nom
                }).ToList();

                ClientBL.CreerClients(nouveauxClients);

                context.ComposantClients.InsertAllOnSubmit(nouveauxClients.Select(x => new ComposantClient
                {
                    ClientId    = x.Id,
                    ComposantId = composantModif.Id
                }));
            }

            //Existing clients
            context.ComposantClients.InsertAllOnSubmit(composantModif.Clients.Where(x => x.Id != 0).Select(x => new ComposantClient
            {
                ClientId    = x.Id,
                ComposantId = composantModif.Id
            }));

            context.SubmitChanges();
        }
Esempio n. 4
0
        private static void ModifierResponsables(GDA_Context context, ComposantModel composantModif)
        {
            var responsables = context.ComposantResponsables.Where(x => x.ComposantId == composantModif.Id);

            context.ComposantResponsables.DeleteAllOnSubmit(responsables);

            //New responsables
            if (composantModif.Responsables.Any(x => x.Id == 0))
            {
                var nouveauxResponsables = composantModif.Responsables.Where(x => x.Id == 0).Select(x => new Responsable
                {
                    Nom = x.Nom
                }).ToList();

                ResponsableBL.CreerResponsables(nouveauxResponsables);

                context.ComposantResponsables.InsertAllOnSubmit(nouveauxResponsables.Select(x => new ComposantResponsable
                {
                    ResponsableId = x.Id,
                    ComposantId   = composantModif.Id
                }));
            }

            //Existing responsables
            context.ComposantResponsables.InsertAllOnSubmit(composantModif.Responsables.Where(x => x.Id != 0).Select(x => new ComposantResponsable
            {
                ResponsableId = x.Id,
                ComposantId   = composantModif.Id
            }));

            context.SubmitChanges();
        }
Esempio n. 5
0
        public static void ModifierComposant(ComposantModel composantModif)
        {
            using (GDA_Context context = new GDA_Context())
            {
                var composant = context.Composants.FirstOrDefault(x => x.Id == composantModif.Id);

                composant.Nom               = composantModif.Nom;
                composant.Abreviation       = composantModif.Abreviation;
                composant.Version           = composantModif.Version;
                composant.Description       = composantModif.Description;
                composant.ComposantTypeId   = composantModif.Type.Id;
                composant.NomBD             = composantModif.NomBD;
                composant.SourceControlPath = composantModif.SourceControlPath;
                composant.BC          = composantModif.BC;
                composant.BW          = composantModif.BW;
                composant.DerniereMAJ = DateTime.Now;

                context.SubmitChanges();

                ModifierClients(context, composantModif);
                ModifierResponsables(context, composantModif);
                ModifierTechnologies(context, composantModif);
                ModifierDependances(context, composantModif);
            }
        }
Esempio n. 6
0
        public static void CreerDeploiement(DeploiementModel nouveauDeploiement)
        {
            using (GDA_Context context = new GDA_Context())
            {
                var deploiement = new Deploiement
                {
                    ComposantId        = nouveauDeploiement.Composant.Id,
                    PremierDeploiement = nouveauDeploiement.PremierDeploiement,
                    Date               = nouveauDeploiement.DateDeploiement,
                    BrancheTag         = nouveauDeploiement.BrancheTag,
                    URLDestination     = nouveauDeploiement.UrlDestination,
                    PortailGroupe      = nouveauDeploiement.PortailGroupe,
                    PortailDescription = nouveauDeploiement.PortailDescription,
                    Details            = nouveauDeploiement.Details,
                    EnvironnementId    = nouveauDeploiement.Environnement.Id,
                    DerniereMAJ        = DateTime.Now,
                    Web       = nouveauDeploiement.Web,
                    BD        = nouveauDeploiement.BD,
                    Rapport   = nouveauDeploiement.Rapport,
                    Interface = nouveauDeploiement.Interface,
                    Job       = nouveauDeploiement.Job
                };

                context.Deploiements.InsertOnSubmit(deploiement);

                context.SubmitChanges();

                nouveauDeploiement.Id = deploiement.Id; //Set the newly inserted id
            }
        }
Esempio n. 7
0
        public static void CreerResponsables(List <Responsable> responsables)
        {
            using (GDA_Context context = new GDA_Context())
            {
                context.Responsables.InsertAllOnSubmit(responsables);

                context.SubmitChanges();
            }
        }
Esempio n. 8
0
        public static void CreerClients(List <Client> clients)
        {
            using (GDA_Context context = new GDA_Context())
            {
                context.Clients.InsertAllOnSubmit(clients);

                context.SubmitChanges();
            }
        }
Esempio n. 9
0
        public static void CreerTechnologies(List <Technologie> technologies)
        {
            using (GDA_Context context = new GDA_Context())
            {
                context.Technologies.InsertAllOnSubmit(technologies);

                context.SubmitChanges();
            }
        }
Esempio n. 10
0
        public static void CreerDependances(List <Dependance> dependances)
        {
            using (GDA_Context context = new GDA_Context())
            {
                context.Dependances.InsertAllOnSubmit(dependances);

                context.SubmitChanges();
            }
        }
Esempio n. 11
0
        public static void SupprimerDeploiement(int id)
        {
            using (GDA_Context context = new GDA_Context())
            {
                var deploiement = context.Deploiements.FirstOrDefault(x => x.Id == id);

                context.Deploiements.DeleteOnSubmit(deploiement);

                context.SubmitChanges();
            }
        }
Esempio n. 12
0
        private static void CreerEnvironnements(GDA_Context context, ComposantModel composant)
        {
            var environnements = context.Environnements.ToList();

            context.ComposantEnvironnements.InsertAllOnSubmit(environnements.Select(x => new ComposantEnvironnement
            {
                ComposantId     = composant.Id,
                EnvironnementId = x.Id,
                Ordre           = x.Ordre
            }));

            context.SubmitChanges();
        }
Esempio n. 13
0
        public static void SupprimerComposant(int id)
        {
            using (GDA_Context context = new GDA_Context())
            {
                var composant = context.Composants.FirstOrDefault(x => x.Id == id);

                context.ComposantClients.DeleteAllOnSubmit(context.ComposantClients.Where(x => x.ComposantId == id));
                context.ComposantDependances.DeleteAllOnSubmit(context.ComposantDependances.Where(x => x.ComposantId == id));
                context.ComposantEnvironnements.DeleteAllOnSubmit(context.ComposantEnvironnements.Where(x => x.ComposantId == id));
                context.ComposantResponsables.DeleteAllOnSubmit(context.ComposantResponsables.Where(x => x.ComposantId == id));
                context.ComposantTechnologies.DeleteAllOnSubmit(context.ComposantTechnologies.Where(x => x.ComposantId == id));
                context.Deploiements.DeleteAllOnSubmit(context.Deploiements.Where(x => x.ComposantId == id));

                context.Composants.DeleteOnSubmit(composant);

                context.SubmitChanges();
            }
        }
Esempio n. 14
0
        private static void ModifierDependances(GDA_Context context, ComposantModel composantModif)
        {
            var dependances = context.ComposantDependances.Where(x => x.ComposantId == composantModif.Id);

            context.ComposantDependances.DeleteAllOnSubmit(dependances);

            //New dependencies
            if (composantModif.RawDependances.Any(x => x.Etiquette.Id == 0))
            {
                var nouvellesDependances = composantModif.RawDependances.Where(x => x.Etiquette.Id == 0).DistinctBy(x => x.Etiquette.Nom).Select(x => new Dependance
                {
                    Nom = x.Etiquette.Nom
                }).ToList();

                DependanceBL.CreerDependances(nouvellesDependances);

                context.ComposantDependances.InsertAllOnSubmit(composantModif.RawDependances.Where(x => x.Etiquette.Id == 0).Select(x => new ComposantDependance
                {
                    DependanceId     = nouvellesDependances.SingleOrDefault(nd => nd.Nom == x.Etiquette.Nom).Id,
                    ComposantId      = composantModif.Id,
                    EnvironnementId  = x.EnvironnementId,
                    DependanceTypeId = x.Type.Id
                }));
            }

            //Existing dependencies
            context.ComposantDependances.InsertAllOnSubmit(composantModif.RawDependances.Where(x => x.Etiquette.Id != 0).Select(x => new ComposantDependance
            {
                DependanceId     = x.Etiquette.Id,
                ComposantId      = composantModif.Id,
                EnvironnementId  = x.EnvironnementId,
                DependanceTypeId = x.Type.Id
            }));

            context.SubmitChanges();
        }
Esempio n. 15
0
        public static void ModifierDeploiement(DeploiementModel deploiementModif)
        {
            using (GDA_Context context = new GDA_Context())
            {
                var deploiement = context.Deploiements.FirstOrDefault(x => x.Id == deploiementModif.Id);
                deploiement.ComposantId        = deploiementModif.Composant.Id;
                deploiement.PremierDeploiement = deploiementModif.PremierDeploiement;
                deploiement.Date               = deploiementModif.DateDeploiement;
                deploiement.BrancheTag         = deploiementModif.BrancheTag;
                deploiement.URLDestination     = deploiementModif.UrlDestination;
                deploiement.PortailGroupe      = deploiementModif.PortailGroupe;
                deploiement.PortailDescription = deploiementModif.PortailDescription;
                deploiement.Details            = deploiementModif.Details;
                deploiement.EnvironnementId    = deploiementModif.Environnement.Id;
                deploiement.DerniereMAJ        = DateTime.Now;
                deploiement.Web       = deploiementModif.Web;
                deploiement.BD        = deploiementModif.BD;
                deploiement.Rapport   = deploiementModif.Rapport;
                deploiement.Interface = deploiementModif.Interface;
                deploiement.Job       = deploiementModif.Job;

                context.SubmitChanges();
            }
        }