Ejemplo n.º 1
0
        /// <inheritdoc />
        public int SaveProgrammation(Programmations newProgrammation)
        {
            using (RatpHidalgoEntities context = new RatpHidalgoEntities(Resource1.RatpConnectionString))
            {
                context.Programmations.Add(newProgrammation);

                context.SaveChanges();

                return(newProgrammation.IdProgrammation);
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public Programmations GetOneProgrammation(int idProgrammation)
        {
            Programmations programmation = null;

            using (RatpHidalgoEntities context = new RatpHidalgoEntities(Resource1.RatpConnectionString))
            {
                programmation = context.Programmations.Where(x => x.IdProgrammation == idProgrammation).SingleOrDefault();
            }

            return(programmation);
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        public void RemoveOneProgrammation(int idProgrammation)
        {
            IEnumerable <ProgrammationDetails>     listProgrammationDetails     = this._uow.HidalgoRepository.GetAllProgrammationDetailsByProgrammation(idProgrammation);
            IEnumerable <ProgrammationDocumentPGE> listProgrammationDocumentPGE = this._uow.HidalgoRepository.GetAllDocumentPgeByProgrammation(idProgrammation);
            IEnumerable <ProgrammationValeurParametresDocument> listProgrammationValeurParametresDocument = this._uow.HidalgoRepository.GetAllProgrammationValeurParametresDocument(idProgrammation);
            Programmations programmation = this._uow.HidalgoRepository.GetOneProgrammation(idProgrammation);

            this.Logger.Info(string.Format("Suppression de la programmation {0}", idProgrammation));
            this._uow.HidalgoRepository.RemoveOneProgrammation(programmation, listProgrammationDetails, listProgrammationDocumentPGE, listProgrammationValeurParametresDocument);
            this.Logger.Info(string.Format("Fin de la Suppression de la programmation {0}", idProgrammation));
        }
Ejemplo n.º 4
0
 /// <inheritdoc />
 public void UpdateProgrammation(Programmations programmation)
 {
     using (RatpHidalgoEntities context = new RatpHidalgoEntities(Resource1.RatpConnectionString))
     {
         var programmationPoco = context.Programmations.Find(programmation.IdProgrammation);
         if (programmationPoco != null)
         {
             programmationPoco.PrixUnitaire     = programmation.PrixUnitaire;
             programmationPoco.BudgetDisponible = programmation.BudgetDisponible;
         }
         context.SaveChanges();
     }
 }
Ejemplo n.º 5
0
        /// <inheritdoc />
        public void RemoveOneProgrammation(Programmations programmation, IEnumerable <ProgrammationDetails> listProgrammationDetails, IEnumerable <ProgrammationDocumentPGE> listProgrammationDocumentPGE, IEnumerable <ProgrammationValeurParametresDocument> listProgrammationValeurParametresDocument)
        {
            //TODO RDT : Base de données passage en casecade au moin pour les [ProgrammationValeurParametresDocument] et si possible aussi pour

            using (RatpHidalgoEntities context = new RatpHidalgoEntities(Resource1.RatpConnectionString))
            {
                //TODO YAF: Rework à faire : préconiser l'Unit of work

                ///Suppression des dependances
                //var programmationDetailToDelete = context.ProgrammationDetails.Find(listProgrammationDetails.Select(x => x.IdProgrammationDetail).ToArray());

                ///Suppression des ProgrammationDetails
                foreach (ProgrammationDetails element in listProgrammationDetails)
                {
                    var programmationDetailToDelete = context.ProgrammationDetails.Find(element.IdProgrammationDetail);
                    context.ProgrammationDetails.Remove(programmationDetailToDelete);
                }//context.ProgrammationDetails.RemoveRange(listProgrammationDetails);

                ///Suppression des Valeurs des Parametres des PGE
                foreach (ProgrammationValeurParametresDocument element in listProgrammationValeurParametresDocument)
                {
                    var programmationValeurToDelete = context.ProgrammationValeurParametresDocument.Find(element.IDParametreHidalgo, element.IDDocumentPge);
                    context.ProgrammationValeurParametresDocument.Remove(programmationValeurToDelete);
                }//context.ProgrammationValeurParametresDocument.RemoveRange(listProgrammationValeurParametresDocument);

                ///Suppression des PGE
                foreach (ProgrammationDocumentPGE element in listProgrammationDocumentPGE)
                {
                    var programmationPgeToDelete = context.ProgrammationDocumentPGE.Find(element.Id);
                    context.ProgrammationDocumentPGE.Remove(programmationPgeToDelete);
                }//context.ProgrammationDocumentPGE.RemoveRange(listProgrammationDocumentPGE);

                ///Suppression de la programmation
                var programmationToDelete = context.Programmations.Find(programmation.IdProgrammation);
                context.Programmations.Remove(programmationToDelete);


                context.SaveChanges();
            }
        }
Ejemplo n.º 6
0
        public Programmations GetOneProgrammationByTypeNatureAnnee(string TypesOuvrages, string natureTravaux, int?anneeProgrammation)
        {
            Programmations programmation = null;

            using (RatpHidalgoEntities context = new RatpHidalgoEntities(Resource1.RatpConnectionString))
            {
                if (anneeProgrammation == 0)
                {
                    programmation = context.Programmations
                                    .Where(x => x.NatureTravaux.Libelle == natureTravaux && x.TypeOuvrage.Libelle == TypesOuvrages)
                                    .OrderByDescending(x => x.DateCreation)
                                    .First();
                }
                else
                {
                    programmation = context.Programmations
                                    .Where(x => x.NatureTravaux.Libelle == natureTravaux && x.TypeOuvrage.Libelle == TypesOuvrages && x.AnneeProgrammation == anneeProgrammation)
                                    .OrderByDescending(x => x.DateCreation)
                                    .FirstOrDefault();
                }
            }

            return(programmation);
        }