Пример #1
0
        protected override Command CreateInsertCommand(Manager entity, IAuthenticatedUser user, string selector)
        {
            var command = Query <Manager>
                          .Single()
                          .Connection(ManagerWithEmployeesConnectionClass.GetConnectionName())
                          .StoredProcedure("[ManagerBoundedContext].[pManager_Insert]")
                          .Parameters(
                p => p.Name("department").Value(entity.Department),
                p => p.Name("name").Value(entity.Name),
                p => p.Name("createdBy").Value(entity.CreatedBy)
                )
                          .OnBeforeCommandExecuted(cmd =>
            {
                var dependencies = Dependencies();

                var managerDependency = (Manager)dependencies?.SingleOrDefault()?.Entity;

                if (managerDependency != null)
                {
                    entity.SupervisorId = managerDependency.Id;
                }

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

            return(command);
        }
Пример #2
0
 protected override Command CreateDeleteCommand(Manager entity, IAuthenticatedUser user, string selector)
 {
     return(Command
            .NonQuery()
            .Connection(ManagerWithEmployeesConnectionClass.GetConnectionName())
            .StoredProcedure("[ManagerBoundedContext].[pManager_Delete]")
            .Parameters(
                p => p.Name("managerId").Value(entity.Id)
                ));
 }
Пример #3
0
        public async override Task <IEnumerable <Manager> > GetAllAsync()
        {
            var result = await Query <Manager>
                         .Collection()
                         .Connection(ManagerWithEmployeesConnectionClass.GetConnectionName())
                         .StoredProcedure("[ManagerBoundedContext].[pManager_GetAll]")
                         .ExecuteAsync();

            return(result.Records);
        }
Пример #4
0
        public async override Task <(int, IEnumerable <Manager>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Manager>
                         .Collection()
                         .Connection(ManagerWithEmployeesConnectionClass.GetConnectionName())
                         .StoredProcedure("[ManagerBoundedContext].[pManager_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
Пример #5
0
        public async override Task <Manager> GetByIdAsync(int managerId)
        {
            var result = await Query <Manager>
                         .Single()
                         .Connection(ManagerWithEmployeesConnectionClass.GetConnectionName())
                         .StoredProcedure("[ManagerBoundedContext].[pManager_GetById]")
                         .Parameters(
                p => p.Name("managerId").Value(managerId)
                )
                         .ExecuteAsync();

            return(result.Record);
        }
Пример #6
0
 protected override Command CreateUpdateCommand(Manager entity, IAuthenticatedUser user, string selector)
 {
     return(Command
            .NonQuery()
            .Connection(ManagerWithEmployeesConnectionClass.GetConnectionName())
            .StoredProcedure("[ManagerBoundedContext].[pManager_Update]")
            .Parameters(
                p => p.Name("managerId").Value(entity.Id),
                p => p.Name("department").Value(entity.Department),
                p => p.Name("name").Value(entity.Name),
                p => p.Name("updatedBy").Value(entity.UpdatedBy),
                p => p.Name("supervisorId").Value(entity.SupervisorId)
                ));
 }
        public async override Task <IEnumerable <Employee> > GetAllAsync()
        {
            var result = await Query <Employee>
                         .Collection()
                         .Connection(ManagerWithEmployeesConnectionClass.GetConnectionName())
                         .StoredProcedure("[ManagerBoundedContext].[pEmployee_GetAll]")
                         .MapTypes(
                4,
                tm => tm.Type(typeof(Manager)).Index(1),
                tm => tm.Type(typeof(Employee)).Index(2)
                )
                         .ExecuteAsync();

            return(result.Records);
        }
        public async override Task <(int, IEnumerable <Employee>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Employee>
                         .Collection()
                         .Connection(ManagerWithEmployeesConnectionClass.GetConnectionName())
                         .StoredProcedure("[ManagerBoundedContext].[pEmployee_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .MapTypes(
                4,
                tm => tm.Type(typeof(Manager)).Index(1),
                tm => tm.Type(typeof(Employee)).Index(2)
                )
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
        public async override Task <Employee> GetByIdAsync(int employeeId)
        {
            var result = await Query <Employee>
                         .Single()
                         .Connection(ManagerWithEmployeesConnectionClass.GetConnectionName())
                         .StoredProcedure("[ManagerBoundedContext].[pEmployee_GetById]")
                         .Parameters(
                p => p.Name("employeeId").Value(employeeId)
                )
                         .MapTypes(
                4,
                tm => tm.Type(typeof(Manager)).Index(1),
                tm => tm.Type(typeof(Employee)).Index(2)
                )
                         .ExecuteAsync();

            return(result.Record);
        }
        public async Task <IEnumerable <Employee> > GetAllEmployeesForManagerAsync(int managerId)
        {
            var result = await Query <Employee>
                         .Collection()
                         .Connection(ManagerWithEmployeesConnectionClass.GetConnectionName())
                         .StoredProcedure("[ManagerBoundedContext].[pManager_GetAllEmployees]")
                         .Parameters(
                p => p.Name("managerId").Value(managerId)
                )
                         .MapTypes(
                4,
                tm => tm.Type(typeof(Manager)).Index(1),
                tm => tm.Type(typeof(Employee)).Index(2)
                )
                         .ExecuteAsync();

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

            return(Command
                   .NonQuery()
                   .Connection(ManagerWithEmployeesConnectionClass.GetConnectionName())
                   .StoredProcedure("[ManagerBoundedContext].[pEmployee_Update]")
                   .Parameters(
                       p => p.Name("employeeId").Value(entity.Id),
                       p => p.Name("name").Value(entity.Name),
                       p => p.Name("updatedBy").Value(entity.UpdatedBy),
                       p => p.Name("supervisorId").Value(entity.SupervisorId)
                       ));
        }
 public SaveManagerCommandAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(ManagerWithEmployeesConnectionClass.GetConnectionName()))
 {
 }
 public SaveManagerCommandAggregate(SaveManagerInputDto manager, EntityDependency[] dependencies = null) : base(new DomainFramework.DataAccess.RepositoryContext(ManagerWithEmployeesConnectionClass.GetConnectionName()))
 {
     Initialize(manager, dependencies);
 }
        public GetAllEmployeesForManagerQueryAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(ManagerWithEmployeesConnectionClass.GetConnectionName()))
        {
            var context = (DomainFramework.DataAccess.RepositoryContext)RepositoryContext;

            EmployeeQueryRepository.Register(context);
        }