Beispiel #1
0
 protected override Command CreateDeleteCommand(Employee entity, IAuthenticatedUser user, string selector)
 {
     return(Command
            .NonQuery()
            .Connection(EmployeeWithDependantsConnectionClass.GetConnectionName())
            .StoredProcedure("[EmployeeBoundedContext].[pEmployee_Delete]")
            .Parameters(
                p => p.Name("employeeId").Value(entity.Id)
                ));
 }
        public async override Task <IEnumerable <Employee> > GetAllAsync()
        {
            var result = await Query <Employee>
                         .Collection()
                         .Connection(EmployeeWithDependantsConnectionClass.GetConnectionName())
                         .StoredProcedure("[EmployeeBoundedContext].[pEmployee_GetAll]")
                         .ExecuteAsync();

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

            return(result.Count, result.Records);
        }
        public async override Task <Employee> GetByIdAsync(int employeeId)
        {
            var result = await Query <Employee>
                         .Single()
                         .Connection(EmployeeWithDependantsConnectionClass.GetConnectionName())
                         .StoredProcedure("[EmployeeBoundedContext].[pEmployee_GetById]")
                         .Parameters(
                p => p.Name("employeeId").Value(employeeId)
                )
                         .ExecuteAsync();

            return(result.Record);
        }
        public async override Task <IEnumerable <Person> > GetAllAsync()
        {
            var result = await Query <Person>
                         .Collection()
                         .Connection(EmployeeWithDependantsConnectionClass.GetConnectionName())
                         .StoredProcedure("[EmployeeBoundedContext].[pPerson_GetAll]")
                         .MapTypes(
                7,
                tm => tm.Type(typeof(Employee)).Index(1),
                tm => tm.Type(typeof(Person)).Index(2)
                )
                         .ExecuteAsync();

            return(result.Records);
        }
Beispiel #6
0
 protected override Command CreateUpdateCommand(Employee entity, IAuthenticatedUser user, string selector)
 {
     return(Command
            .NonQuery()
            .Connection(EmployeeWithDependantsConnectionClass.GetConnectionName())
            .StoredProcedure("[EmployeeBoundedContext].[pEmployee_Update]")
            .Parameters(
                p => p.Name("employeeId").Value(entity.Id),
                p => p.Name("hireDate").Value(entity.HireDate),
                p => p.Name("name").Value(entity.Name),
                p => p.Name("updatedBy").Value(entity.UpdatedBy),
                p => p.Name("cellPhone_AreaCode").Value(entity.CellPhone.AreaCode),
                p => p.Name("cellPhone_Exchange").Value(entity.CellPhone.Exchange),
                p => p.Name("cellPhone_Number").Value(entity.CellPhone.Number),
                p => p.Name("providerEmployeeId").Value(entity.ProviderEmployeeId)
                ));
 }
        public async override Task <(int, IEnumerable <Person>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Person>
                         .Collection()
                         .Connection(EmployeeWithDependantsConnectionClass.GetConnectionName())
                         .StoredProcedure("[EmployeeBoundedContext].[pPerson_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .MapTypes(
                7,
                tm => tm.Type(typeof(Employee)).Index(1),
                tm => tm.Type(typeof(Person)).Index(2)
                )
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
        public async override Task <Person> GetByIdAsync(int personId)
        {
            var result = await Query <Person>
                         .Single()
                         .Connection(EmployeeWithDependantsConnectionClass.GetConnectionName())
                         .StoredProcedure("[EmployeeBoundedContext].[pPerson_GetById]")
                         .Parameters(
                p => p.Name("personId").Value(personId)
                )
                         .MapTypes(
                7,
                tm => tm.Type(typeof(Employee)).Index(1),
                tm => tm.Type(typeof(Person)).Index(2)
                )
                         .ExecuteAsync();

            return(result.Record);
        }
        public async Task <IEnumerable <Person> > GetAllDependantsForEmployeeAsync(int employeeId)
        {
            var result = await Query <Person>
                         .Collection()
                         .Connection(EmployeeWithDependantsConnectionClass.GetConnectionName())
                         .StoredProcedure("[EmployeeBoundedContext].[pEmployee_GetAllDependants]")
                         .Parameters(
                p => p.Name("employeeId").Value(employeeId)
                )
                         .MapTypes(
                7,
                tm => tm.Type(typeof(Employee)).Index(1),
                tm => tm.Type(typeof(Person)).Index(2)
                )
                         .ExecuteAsync();

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

            var command = Query <Person>
                          .Single()
                          .Connection(EmployeeWithDependantsConnectionClass.GetConnectionName())
                          .StoredProcedure("[EmployeeBoundedContext].[pPerson_Insert]")
                          .Parameters(
                p => p.Name("name").Value(entity.Name),
                p => p.Name("createdBy").Value(entity.CreatedBy),
                p => p.Name("cellPhone_AreaCode").Value(entity.CellPhone.AreaCode),
                p => p.Name("cellPhone_Exchange").Value(entity.CellPhone.Exchange),
                p => p.Name("cellPhone_Number").Value(entity.CellPhone.Number)
                )
                          .OnBeforeCommandExecuted(cmd =>
            {
                var dependencies = Dependencies();

                var employeeDependency = (Employee)dependencies?.SingleOrDefault()?.Entity;

                if (employeeDependency != null)
                {
                    entity.ProviderEmployeeId = employeeDependency.Id;
                }

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

            return(command);
        }
Beispiel #11
0
 public SaveEmployeeCommandAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(EmployeeWithDependantsConnectionClass.GetConnectionName()))
 {
 }
Beispiel #12
0
 public SaveEmployeeCommandAggregate(SaveEmployeeInputDto employee, EntityDependency[] dependencies = null) : base(new DomainFramework.DataAccess.RepositoryContext(EmployeeWithDependantsConnectionClass.GetConnectionName()))
 {
     Initialize(employee, dependencies);
 }