protected override Command CreateDeleteLinksCommand(Organization entity, IAuthenticatedUser user, string selector)
        {
            switch (selector)
            {
            case "UnlinkAddressFromOrganization": return(Command
                                                         .NonQuery()
                                                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                                                         .StoredProcedure("[OrganizationPersonBoundedContext].[pOrganization_UnlinkAddress]")
                                                         .ThrowWhenNoRecordIsUpdated(false)
                                                         .Parameters(
                                                             p => p.Name("organizationId").Value(entity.Id)
                                                             ));

            case "UnlinkPhonesFromOrganization": return(Command
                                                        .NonQuery()
                                                        .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                                                        .StoredProcedure("[OrganizationPersonBoundedContext].[pOrganization_UnlinkPhones]")
                                                        .ThrowWhenNoRecordIsUpdated(false)
                                                        .Parameters(
                                                            p => p.Name("organizationId").Value(entity.Id)
                                                            ));

            default: throw new InvalidOperationException();
            }
        }
        public override IEnumerable <Address> GetAll()
        {
            var result = Query <Address>
                         .Collection()
                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                         .StoredProcedure("[OrganizationPersonBoundedContext].[pAddress_GetAll]")
                         .Execute();

            return(result.Records);
        }
 protected override Command CreateDeleteCommand(Organization entity, IAuthenticatedUser user, string selector)
 {
     return(Command
            .NonQuery()
            .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
            .StoredProcedure("[OrganizationPersonBoundedContext].[pOrganization_Delete]")
            .Parameters(
                p => p.Name("organizationId").Value(entity.Id)
                ));
 }
        public async override Task <IEnumerable <Organization> > GetAllAsync()
        {
            var result = await Query <Organization>
                         .Collection()
                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                         .StoredProcedure("[OrganizationPersonBoundedContext].[pOrganization_GetAll]")
                         .ExecuteAsync();

            return(result.Records);
        }
        public override (int, IEnumerable <Address>) Get(CollectionQueryParameters queryParameters)
        {
            var result = Query <Address>
                         .Collection()
                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                         .StoredProcedure("[OrganizationPersonBoundedContext].[pAddress_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Execute();

            return(result.Count, result.Records);
        }
        public async override Task <(int, IEnumerable <Organization>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Organization>
                         .Collection()
                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                         .StoredProcedure("[OrganizationPersonBoundedContext].[pOrganization_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
Ejemplo n.º 7
0
        public IEnumerable <Phone> GetAllPhonesForOrganization(int organizationId)
        {
            var result = Query <Phone>
                         .Collection()
                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                         .StoredProcedure("[OrganizationPersonBoundedContext].[pOrganization_GetAllPhones]")
                         .Parameters(
                p => p.Name("organizationId").Value(organizationId)
                )
                         .Execute();

            return(result.Records);
        }
Ejemplo n.º 8
0
        public async Task <IEnumerable <Phone> > GetAllPhonesForPersonAsync(int personId)
        {
            var result = await Query <Phone>
                         .Collection()
                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                         .StoredProcedure("[OrganizationPersonBoundedContext].[pPerson_GetAllPhones]")
                         .Parameters(
                p => p.Name("personId").Value(personId)
                )
                         .ExecuteAsync();

            return(result.Records);
        }
        public async Task <Address> GetAddressForPersonAsync(int personId)
        {
            var result = await Query <Address>
                         .Single()
                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                         .StoredProcedure("[OrganizationPersonBoundedContext].[pPerson_GetAddress]")
                         .Parameters(
                p => p.Name("personId").Value(personId)
                )
                         .ExecuteAsync();

            return(result.Record);
        }
        public async override Task <Organization> GetByIdAsync(int organizationId)
        {
            var result = await Query <Organization>
                         .Single()
                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                         .StoredProcedure("[OrganizationPersonBoundedContext].[pOrganization_GetById]")
                         .Parameters(
                p => p.Name("organizationId").Value(organizationId)
                )
                         .ExecuteAsync();

            return(result.Record);
        }
        public Address GetAddressForOrganization(int organizationId)
        {
            var result = Query <Address>
                         .Single()
                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                         .StoredProcedure("[OrganizationPersonBoundedContext].[pOrganization_GetAddress]")
                         .Parameters(
                p => p.Name("organizationId").Value(organizationId)
                )
                         .Execute();

            return(result.Record);
        }
        public override Address GetById(int addressId)
        {
            var result = Query <Address>
                         .Single()
                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                         .StoredProcedure("[OrganizationPersonBoundedContext].[pAddress_GetById]")
                         .Parameters(
                p => p.Name("addressId").Value(addressId)
                )
                         .Execute();

            return(result.Record);
        }
Ejemplo n.º 13
0
        public (int, IEnumerable <Phone>) GetPhonesForPerson(int personId, CollectionQueryParameters queryParameters)
        {
            var result = Query <Phone>
                         .Collection()
                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                         .StoredProcedure("[OrganizationPersonBoundedContext].[pPerson_GetPhones]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Parameters(
                p => p.Name("personId").Value(personId)
                )
                         .Execute();

            return(result.Count, result.Records);
        }
        protected override Command CreateUpdateCommand(Organization entity, IAuthenticatedUser user, string selector)
        {
            if (user != null)
            {
                entity.UpdatedBy = (int)user.Id;
            }

            return(Command
                   .NonQuery()
                   .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                   .StoredProcedure("[OrganizationPersonBoundedContext].[pOrganization_Update]")
                   .Parameters(
                       p => p.Name("organizationId").Value(entity.Id),
                       p => p.Name("name").Value(entity.Name),
                       p => p.Name("updatedBy").Value(entity.UpdatedBy)
                       ));
        }
        protected override Command CreateInsertCommand(Address entity, IAuthenticatedUser user, string selector)
        {
            if (user != null)
            {
                entity.CreatedBy = (int)user.Id;
            }

            var command = Query <Address>
                          .Single()
                          .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                          .StoredProcedure("[OrganizationPersonBoundedContext].[pAddress_Insert]")
                          .Parameters(
                p => p.Name("street").Value(entity.Street),
                p => p.Name("createdBy").Value(entity.CreatedBy)
                )
                          .OnBeforeCommandExecuted(cmd =>
            {
                var dependencies = Dependencies();

                var addressDependency = dependencies?.SingleOrDefault(d => d.Selector == "Address")?.Entity;

                if (addressDependency is Organization)
                {
                    var organizationDependency = (Organization)addressDependency;

                    cmd.Parameters(
                        p => p.Name("organizationId").Value(organizationDependency.Id)
                        );
                }
                else if (addressDependency is Person)
                {
                    var personDependency = (Person)addressDependency;

                    cmd.Parameters(
                        p => p.Name("personId").Value(personDependency.Id)
                        );
                }
            })
                          .RecordInstance(entity)
                          .MapProperties(
                p => p.Name("Id").Index(0)
                );

            return(command);
        }
        protected override Command CreateInsertCommand(Organization entity, IAuthenticatedUser user, string selector)
        {
            if (user != null)
            {
                entity.CreatedBy = (int)user.Id;
            }

            var command = Query <Organization>
                          .Single()
                          .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                          .StoredProcedure("[OrganizationPersonBoundedContext].[pOrganization_Insert]")
                          .Parameters(
                p => p.Name("name").Value(entity.Name),
                p => p.Name("createdBy").Value(entity.CreatedBy)
                )
                          .RecordInstance(entity)
                          .MapProperties(
                p => p.Name("Id").Index(0)
                );

            return(command);
        }
 public SavePersonCommandAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName()))
 {
 }
 public SavePersonCommandAggregate(SavePersonInputDto organization, EntityDependency[] dependencies = null) : base(new DomainFramework.DataAccess.RepositoryContext(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName()))
 {
     Initialize(organization, dependencies);
 }