Пример #1
0
        public override IEnumerable <Address> GetAll()
        {
            var result = Query <Address>
                         .Collection()
                         .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                         .StoredProcedure("[SchoolBoundedContext].[pAddress_GetAll]")
                         .Execute();

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

            return(result.Records);
        }
Пример #4
0
 protected override Command CreateDeleteLinksCommand(School entity, IAuthenticatedUser user, string selector)
 {
     return(Command
            .NonQuery()
            .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
            .StoredProcedure("[SchoolBoundedContext].[pRole_UnlinkOrganization]")
            .ThrowWhenNoRecordIsUpdated(false)
            .Parameters(
                p => p.Name("roleId").Value(entity.Id)
                ));
 }
Пример #5
0
        public override (int, IEnumerable <Address>) Get(CollectionQueryParameters queryParameters)
        {
            var result = Query <Address>
                         .Collection()
                         .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                         .StoredProcedure("[SchoolBoundedContext].[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(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                         .StoredProcedure("[SchoolBoundedContext].[pOrganization_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
Пример #7
0
        public override Address GetById(int addressId)
        {
            var result = Query <Address>
                         .Single()
                         .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                         .StoredProcedure("[SchoolBoundedContext].[pAddress_GetById]")
                         .Parameters(
                p => p.Name("addressId").Value(addressId)
                )
                         .Execute();

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

            return(result.Record);
        }
Пример #9
0
        public Address GetAddressForOrganization(int organizationId)
        {
            var result = Query <Address>
                         .Single()
                         .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                         .StoredProcedure("[SchoolBoundedContext].[pOrganization_GetAddress]")
                         .Parameters(
                p => p.Name("organizationId").Value(organizationId)
                )
                         .Execute();

            return(result.Record);
        }
        public Organization GetOrganizationForRole(int roleId)
        {
            var result = Query <Organization>
                         .Single()
                         .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                         .StoredProcedure("[SchoolBoundedContext].[pRole_GetOrganization]")
                         .Parameters(
                p => p.Name("roleId").Value(roleId)
                )
                         .Execute();

            return(result.Record);
        }
Пример #11
0
        public async override Task <IEnumerable <Role> > GetAllAsync()
        {
            var result = await Query <Role>
                         .Collection()
                         .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                         .StoredProcedure("[SchoolBoundedContext].[pRole_GetAll]")
                         .MapTypes(
                2,
                tm => tm.Type(typeof(School)).Index(1),
                tm => tm.Type(typeof(Role)).Index(2)
                )
                         .ExecuteAsync();

            return(result.Records);
        }
Пример #12
0
        protected override Command CreateUpdateCommand(Role entity, IAuthenticatedUser user, string selector)
        {
            if (user != null)
            {
                entity.UpdatedBy = (int)user.Id;
            }

            return(Command
                   .NonQuery()
                   .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                   .StoredProcedure("[SchoolBoundedContext].[pRole_Update]")
                   .Parameters(
                       p => p.Name("roleId").Value(entity.Id),
                       p => p.Name("updatedBy").Value(entity.UpdatedBy)
                       ));
        }
        protected override Command CreateInsertCommand(Address entity, IAuthenticatedUser user, string selector)
        {
            var command = Query <Address>
                          .Single()
                          .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                          .StoredProcedure("[SchoolBoundedContext].[pAddress_Insert]")
                          .Parameters(
                p => p.Name("street").Value(entity.Street)
                )
                          .RecordInstance(entity)
                          .MapProperties(
                p => p.Name("Id").Index(0)
                );

            return(command);
        }
Пример #14
0
        public async override Task <(int, IEnumerable <Role>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Role>
                         .Collection()
                         .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                         .StoredProcedure("[SchoolBoundedContext].[pRole_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .MapTypes(
                2,
                tm => tm.Type(typeof(School)).Index(1),
                tm => tm.Type(typeof(Role)).Index(2)
                )
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
Пример #15
0
        public override Role GetById(int roleId)
        {
            var result = Query <Role>
                         .Single()
                         .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                         .StoredProcedure("[SchoolBoundedContext].[pRole_GetById]")
                         .Parameters(
                p => p.Name("roleId").Value(roleId)
                )
                         .MapTypes(
                2,
                tm => tm.Type(typeof(School)).Index(1),
                tm => tm.Type(typeof(Role)).Index(2)
                )
                         .Execute();

            return(result.Record);
        }
Пример #16
0
        protected override Command CreateInsertCommand(Role entity, IAuthenticatedUser user, string selector)
        {
            if (user != null)
            {
                entity.CreatedBy = (int)user.Id;
            }

            var command = Query <Role>
                          .Single()
                          .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                          .StoredProcedure("[SchoolBoundedContext].[pRole_Insert]")
                          .Parameters(
                p => p.Name("createdBy").Value(entity.CreatedBy)
                )
                          .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(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                          .StoredProcedure("[SchoolBoundedContext].[pOrganization_Insert]")
                          .Parameters(
                p => p.Name("name").Value(entity.Name),
                p => p.Name("createdBy").Value(entity.CreatedBy),
                p => p.Name("phone_Number").Value(entity.Phone.Number)
                )
                          .OnBeforeCommandExecuted(cmd =>
            {
                var dependencies = Dependencies();

                var addressDependency = (Address)dependencies?.SingleOrDefault()?.Entity;

                if (addressDependency != null)
                {
                    entity.AddressId = addressDependency.Id;
                }

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

            return(command);
        }
 public SaveOrganizationCommandAggregate(OrganizationInputDto organization, EntityDependency[] dependencies = null) : base(new DomainFramework.DataAccess.RepositoryContext(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName()))
 {
     Initialize(organization, dependencies);
 }
        protected override Command CreateInsertCommand(OrganizationRole entity, IAuthenticatedUser user, string selector)
        {
            if (user != null)
            {
                entity.CreatedBy = (int)user.Id;
            }

            var command = Command
                          .NonQuery()
                          .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                          .StoredProcedure("[SchoolBoundedContext].[pOrganizationRole_Insert]")
                          .Parameters(
                p => p.Name("createdBy").Value(entity.CreatedBy)
                )
                          .OnBeforeCommandExecuted(cmd =>
            {
                var dependencies = Dependencies();

                if (!dependencies.Any())
                {
                    cmd.Parameters(
                        p => p.Name("organizationId").Value(entity.Id.OrganizationId),
                        p => p.Name("roleId").Value(entity.Id.RoleId)
                        );
                }
                else
                {
                    switch (selector)
                    {
                    case "Organization":
                        {
                            var role = (Role)dependencies.ElementAt(0).Entity;

                            cmd.Parameters(
                                p => p.Name("organizationId").Value(entity.Id.OrganizationId),
                                p => p.Name("roleId").Value(role.Id)
                                );
                        }
                        break;

                    case "Role":
                        {
                            var organization = (Organization)dependencies.ElementAt(0).Entity;

                            cmd.Parameters(
                                p => p.Name("organizationId").Value(organization.Id),
                                p => p.Name("roleId").Value(entity.Id.RoleId)
                                );
                        }
                        break;

                    default:
                        {
                            var organization = (Organization)dependencies.Single(d => d.Selector == "Organization").Entity;

                            var role = (Role)dependencies.Single(d => d.Selector == "Role").Entity;

                            entity.Id = new OrganizationRoleId
                            {
                                OrganizationId = organization.Id,
                                RoleId         = role.Id
                            };

                            cmd.Parameters(
                                p => p.Name("organizationId").Value(organization.Id),
                                p => p.Name("roleId").Value(role.Id)
                                );
                        }
                        break;
                    }
                }
            });

            return(command);
        }
 public SaveOrganizationCommandAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName()))
 {
 }