コード例 #1
0
 public static void AppsDelete(this ContactMechanism @this, DeletableDelete method)
 {
     foreach (PartyContactMechanism partyContactMechanism in @this.PartyContactMechanismsWhereContactMechanism)
     {
         partyContactMechanism.Delete();
     }
 }
コード例 #2
0
        public static void AppsOnPreDerive(this ContactMechanism @this, ObjectOnPreDerive method)
        {
            var derivation = method.Derivation;

            foreach (PartyContactMechanism partyContactMechanism in @this.PartyContactMechanismsWhereContactMechanism)
            {
                derivation.AddDependency(partyContactMechanism, @this);
            }
        }
コード例 #3
0
        public ElectronicAddressEditPage SelectElectronicAddress(ContactMechanism contactMechanism)
        {
            this.ContactMechanismPanel.Click();

            var row  = this.Table.FindRow(contactMechanism);
            var cell = row.FindCell("contact");

            cell.Click();

            return(new ElectronicAddressEditPage(this.Driver));
        }
コード例 #4
0
        public TelecommunicationsNumberEditPage SelectTelecommunicationsNumber(ContactMechanism ContactMechanism)
        {
            this.ContactMechanismPanel.Click();

            var row  = this.Table.FindRow(ContactMechanism);
            var cell = row.FindCell("contact");

            cell.Click();

            return(new TelecommunicationsNumberEditPage(this.Driver));
        }
コード例 #5
0
        public static void BaseOnPreDerive(this ContactMechanism @this, ObjectOnPreDerive method)
        {
            var(iteration, changeSet, derivedObjects) = method;

            if (iteration.IsMarked(@this) || changeSet.IsCreated(@this) || changeSet.HasChangedRoles(@this))
            {
                foreach (PartyContactMechanism partyContactMechanism in @this.PartyContactMechanismsWhereContactMechanism)
                {
                    iteration.AddDependency(partyContactMechanism, @this);
                    iteration.Mark(partyContactMechanism);
                }
            }
        }
コード例 #6
0
 private PartyContactMechanism CreatePartyContactMechanism(ContactMechanismPurpose purpose, ContactMechanism mechanism) =>
 new PartyContactMechanismBuilder(this.Session)
 .WithContactPurpose(purpose)
 .WithContactMechanism(mechanism)
 .WithUseAsDefault(true)
 .Build();
コード例 #7
0
 private PartyContactMechanism CreateShipTo(ContactMechanism mechanism, ContactMechanismPurpose purpose, bool isDefault)
 => new PartyContactMechanismBuilder(this.Session).WithContactMechanism(mechanism).WithContactPurpose(purpose).WithUseAsDefault(isDefault).Build();
コード例 #8
0
        public async Task <ServiceResponse <string> > Register(UserRegisterDto user)
        {
            var response = new ServiceResponse <string>();

            try
            {
                if (await UserExists(user.Username))
                {
                    response.Success = false;
                    response.Message = "User already exists.";
                    return(response);
                }

                CreatePasswordHash(user.Password, out byte[] passwordHash, out byte[] passwordSalt);

                //create new party
                var party = new Party
                {
                    //create new guid
                    Uuid                = Guid.NewGuid().ToString().ToUpper(),
                    CreateDate          = DateTime.UtcNow,
                    LastUpdateTimestamp = DateTime.UtcNow
                };

                await context.Party.AddAsync(party);

                //save to get the party id
                await context.SaveChangesAsync();

                //create person
                var person = new Person
                {
                    PersonId            = party.PartyId,
                    FullName            = user.FullName,
                    PlatformUserName    = user.Username,
                    LastUpdateTimestamp = DateTime.UtcNow
                };

                await context.Person.AddAsync(person);

                //save to get the person id
                await context.SaveChangesAsync();

                //create person as user
                var actorType = ActorType.Owner;

                var participantType = await context.PlatformParticipantType
                                      .Where(x => x.ParticipantTypeIndicator == actorType.GetDescription()).FirstOrDefaultAsync();

                var personAsUser = new PersonAsUser
                {
                    PersonFk                  = person.PersonId,
                    Uuid                      = Guid.NewGuid().ToString().ToUpper(),
                    MobileBusinessFk          = null,
                    PasswordBin               = passwordHash,
                    PasswordSalt              = passwordSalt,
                    PlatformParticipantTypeFk = participantType.PlatformParticipantTypeId,
                    LastUpdateTimestamp       = DateTime.UtcNow
                };

                await context.PersonAsUser.AddAsync(personAsUser);

                //save to get the person as user id
                await context.SaveChangesAsync();

                //save the person id
                var personId = (int)person.PersonId;

                //create new contact mechanism uuid
                var cm = new ContactMechanism()
                {
                    Uuid = Guid.NewGuid().ToString(),
                    LastUpdateTimestamp = DateTime.UtcNow
                };

                await context.ContactMechanism.AddAsync(cm);

                //need to save here to get the contact mechanism id!!
                await context.SaveChangesAsync();

                //create Email Address
                var email = new EmailAddress()
                {
                    EmailAddressId      = cm.ContactMechanismId,
                    Email               = user.Username,
                    EmailTypeCode       = user.EmailTypeCode ?? "P",
                    LastUpdateTimestamp = DateTime.UtcNow
                };

                await context.EmailAddress.AddAsync(email);

                await context.SaveChangesAsync();

                response.Data = $"User {person.PlatformUserName} created.";
            }
            catch (Exception ex)
            {
                //create user friendly exception
                response.Success   = false;
                response.Message   = ex.Message;
                response.Exception = new PlatformScreenException(ex);
            }

            return(response);
        }