Example #1
0
        public long NewLock(EquinoxeExtend.Shared.Object.Record.Lock iNewLock)
        {
            if (iNewLock.DossierId < 1)
            {
                throw new Exception("L'id du dossier est invalide");
            }

            if (iNewLock.LockDate == null)
            {
                throw new Exception("La date du lock n'est pas valide");
            }

            if (iNewLock.LockId != -1)
            {
                throw new Exception("L'id du lock est invalide");
            }

            if (iNewLock.SessionGUID == null)
            {
                throw new Exception("Le GUID de session est invalide");
            }

            if (iNewLock.UserId == null)
            {
                throw new Exception("L'id du user est invalide");
            }

            if (DBRecordDataService.Any <T_E_Lock>(x => x.DossierId == iNewLock.DossierId))
            {
                throw new Exception("Un lock est déjà posé sur le dossier '{0}'".FormatString(iNewLock.DossierId.ToString()));
            }

            //Création de l'enregistrement
            var newEntity = new T_E_Lock();

            newEntity.Merge(iNewLock);

            return(DBRecordDataService.Add <T_E_Lock>(newEntity).LockId);
        }