Esempio n. 1
0
        internal static void UpdatePerson(UserRegistration user, string orgPersonUuid)
        {
            if (orgPersonUuid != null && (user.Person.Uuid == null || orgPersonUuid.Equals(user.Person.Uuid)))
            {
                // This is the expected case for an update operation - see if we have updates for the referenced Person object

                personStub.Ret(orgPersonUuid, user.Person.Name, user.Person.ShortKey, user.Person.Cpr, user.Timestamp);

                // ensure that we have the uuid of the person in the user object, as we will need it for later
                user.Person.Uuid = orgPersonUuid;
            }
            else
            {
                // This is either because no Person object existed for the User (first time creation), or because
                // the local supplied uuid of the Person object differs from the one stored in Organisation. In both
                // cases we need to create the Person object from scratch

                PersonData personData = new PersonData()
                {
                    Cpr       = user.Person.Cpr,
                    Name      = user.Person.Name,
                    ShortKey  = user.Person.ShortKey,
                    Timestamp = user.Timestamp,
                    Uuid      = user.Person.Uuid
                };

                // TODO: this could potentially fail if we are re-using a Person object locally - but we really don't want to support that case
                personStub.Importer(personData);

                // ensure that we have the uuid of the person in the user object, as we will need it for later
                user.Person.Uuid = personData.Uuid;
            }
        }
Esempio n. 2
0
        internal static void UpdatePerson(UserRegistration user, string orgPersonUuid, out string uuid)
        {
            uuid = orgPersonUuid; // default

            if (orgPersonUuid != null)
            {
                // This is the expected case for an update operation - see if we have updates for the referenced Person object

                personStub.Ret(orgPersonUuid, user.Person.Name, user.Person.Cpr, user.Timestamp);
            }
            else
            {
                // This is either because no Person object existed for the User (first time creation), or because
                // the local supplied uuid of the Person object differs from the one stored in Organisation. In both
                // cases we need to create the Person object from scratch

                PersonData personData = new PersonData()
                {
                    Cpr       = user.Person.Cpr,
                    Name      = user.Person.Name,
                    ShortKey  = IdUtil.GenerateShortKey(),
                    Timestamp = user.Timestamp,
                    Uuid      = IdUtil.GenerateUuid()
                };

                personStub.Importer(personData);

                // ensure that we have the uuid of the person in the user object, as we will need it for later
                uuid = personData.Uuid;
            }
        }