Пример #1
0
        public void NewDossier(EquinoxeExtend.Shared.Object.Record.Dossier iNewDossier)
        {
            if (iNewDossier.DossierId != -1)
            {
                throw new Exception("L'Id de la spécification est invalide");
            }

            if (iNewDossier.Name.IsNullOrEmpty())
            {
                throw new Exception("Le nom du dossier est invalide");
            }

            if (iNewDossier.ProjectName.IsNullOrEmpty())
            {
                throw new Exception("Le nom du projet est invalide");
            }

            if (DBRecordDataService.Any <T_E_Dossier>(x => x.Name == iNewDossier.Name))
            {
                throw new Exception("Le dossier existe déjà");
            }

            if (iNewDossier.Specifications.Enum().Count() != 1)
            {
                throw new Exception("Le nombre de spécification doit être égal à 1");
            }

            if (iNewDossier.IsTemplate)
            {
                if (iNewDossier.TemplateName.IsNullOrEmpty())
                {
                    throw new Exception("Le nom du template n'est pas valide");
                }
                if (DBRecordDataService.Any <T_E_Dossier>(x => x.TemplateName == iNewDossier.TemplateName))
                {
                    throw new Exception("Le nom du template est déjà existant");
                }
            }

            using (var ts = new TransactionScope())
            {
                var newSpecification = iNewDossier.Specifications.Single();

                //Création du Dossier
                var newEntity = new T_E_Dossier();
                newEntity.Merge(iNewDossier);

                newSpecification.DossierId = DBRecordDataService.AddDossier(newEntity);

                //Création de la Spécification
                NewSpecification(newSpecification);

                ts.Complete();
            }
        }
 public static void Merge(this T_E_Dossier iEntity, Dossier iObj)
 {
     iEntity.DossierId                   = iObj.DossierId;
     iEntity.Name                        = iObj.Name;
     iEntity.ProjectName                 = iObj.ProjectName;
     iEntity.IsTemplate                  = iObj.IsTemplate;
     iEntity.TemplateName                = iObj.TemplateName;
     iEntity.TemplateDescription         = iObj.TemplateDescription;
     iEntity.IsCreateVersionOnGeneration = iObj.IsCreateVersionOnGeneration;
     iEntity.StateCommercialRef          = (short)iObj.StateCommercial;
     iEntity.StateDesignRef              = (short)iObj.StateDesign;
     iEntity.DesignDate                  = iObj.DesignDate;
     iEntity.DesignNameGUID              = iObj.DesignNameGUID;
 }
Пример #3
0
        public void UpdateDossier(EquinoxeExtend.Shared.Object.Record.Dossier iDossier)
        {
            if (iDossier.Name.IsNullOrEmpty())
            {
                throw new Exception("Le nom du dossier est invalide");
            }

            if (DBRecordDataService.Any <T_E_Dossier>(x => x.Name == iDossier.Name) == false)
            {
                throw new Exception("Le dossier est inexistant");
            }

            var theEntity = new T_E_Dossier();

            theEntity.Merge(iDossier);
            DBRecordDataService.Update(theEntity);
        }