protected override Command CreateUpdateCommand(Employee entity, IAuthenticatedUser user, string selector) { return(Command .NonQuery() .Connection(EmployeeWithSpouseConnectionClass.GetConnectionName()) .StoredProcedure("[EmployeeBoundedContext].[pEmployee_Update]") .Parameters( 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) ) .OnBeforeCommandExecuted(cmd => { var dependencies = Dependencies(); cmd.Parameters( p => p.Name("employeeId").Value(entity.Id) ); var entityForSpouse = (Person)dependencies.SingleOrDefault(d => d.Selector == "Spouse")?.Entity; if (entityForSpouse != null) { entity.MarriedToPersonId = entityForSpouse.Id; } cmd.Parameters( p => p.Name("marriedToPersonId").Value(entity.MarriedToPersonId) ); })); }
public async override Task <IEnumerable <Employee> > GetAllAsync() { var result = await Query <Employee> .Collection() .Connection(EmployeeWithSpouseConnectionClass.GetConnectionName()) .StoredProcedure("[EmployeeBoundedContext].[pEmployee_GetAll]") .ExecuteAsync(); return(result.Records); }
protected override Command CreateDeleteCommand(Employee entity, IAuthenticatedUser user, string selector) { return(Command .NonQuery() .Connection(EmployeeWithSpouseConnectionClass.GetConnectionName()) .StoredProcedure("[EmployeeBoundedContext].[pEmployee_Delete]") .Parameters( p => p.Name("employeeId").Value(entity.Id) )); }
protected override Command CreateDeleteLinksCommand(Employee entity, IAuthenticatedUser user, string selector) { return(Command .NonQuery() .Connection(EmployeeWithSpouseConnectionClass.GetConnectionName()) .StoredProcedure("[EmployeeBoundedContext].[pPerson_UnlinkSpouse]") .ThrowWhenNoRecordIsUpdated(false) .Parameters( p => p.Name("personId").Value(entity.Id) )); }
public async override Task <(int, IEnumerable <Employee>)> GetAsync(CollectionQueryParameters queryParameters) { var result = await Query <Employee> .Collection() .Connection(EmployeeWithSpouseConnectionClass.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(EmployeeWithSpouseConnectionClass.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(EmployeeWithSpouseConnectionClass.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); }
public async override Task <(int, IEnumerable <Person>)> GetAsync(CollectionQueryParameters queryParameters) { var result = await Query <Person> .Collection() .Connection(EmployeeWithSpouseConnectionClass.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 Person GetSpouseForPerson(int personId) { var result = Query <Person> .Single() .Connection(EmployeeWithSpouseConnectionClass.GetConnectionName()) .StoredProcedure("[EmployeeBoundedContext].[pPerson_GetSpouse]") .Parameters( p => p.Name("personId").Value(personId) ) .MapTypes( 7, tm => tm.Type(typeof(Employee)).Index(1), tm => tm.Type(typeof(Person)).Index(2) ) .Execute(); return(result.Record); }
protected override Command CreateInsertCommand(Person entity, IAuthenticatedUser user, string selector) { if (user != null) { entity.CreatedBy = (int)user.Id; } var command = Query <Person> .Single() .Connection(EmployeeWithSpouseConnectionClass.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 marriedToDependency = (Person)dependencies?.SingleOrDefault()?.Entity; if (marriedToDependency != null) { entity.MarriedToPersonId = marriedToDependency.Id; } cmd.Parameters( p => p.Name("marriedToPersonId").Value(entity.MarriedToPersonId) ); }) .RecordInstance(entity) .MapProperties( p => p.Name("Id").Index(0) ); return(command); }
public SaveEmployeeCommandAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(EmployeeWithSpouseConnectionClass.GetConnectionName())) { }
public SaveEmployeeCommandAggregate(SaveEmployeeInputDto employee, EntityDependency[] dependencies = null) : base(new DomainFramework.DataAccess.RepositoryContext(EmployeeWithSpouseConnectionClass.GetConnectionName())) { Initialize(employee, dependencies); }