Пример #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);
        }