public async override Task <IEnumerable <Person> > GetAllAsync() { var result = await Query <Person> .Collection() .Connection(PersonWithSpouseConnectionClass.GetConnectionName()) .StoredProcedure("[PersonBoundedContext].[pPerson_GetAll]") .ExecuteAsync(); return(result.Records); }
protected override Command CreateDeleteCommand(Person entity, IAuthenticatedUser user, string selector) { return(Command .NonQuery() .Connection(PersonWithSpouseConnectionClass.GetConnectionName()) .StoredProcedure("[PersonBoundedContext].[pPerson_Delete]") .Parameters( p => p.Name("personId").Value(entity.Id) )); }
protected override Command CreateDeleteLinksCommand(Person entity, IAuthenticatedUser user, string selector) { return(Command .NonQuery() .Connection(PersonWithSpouseConnectionClass.GetConnectionName()) .StoredProcedure("[PersonBoundedContext].[pPerson_UnlinkMarriedTo]") .ThrowWhenNoRecordIsUpdated(false) .Parameters( p => p.Name("personId").Value(entity.Id) )); }
public async override Task <(int, IEnumerable <Person>)> GetAsync(CollectionQueryParameters queryParameters) { var result = await Query <Person> .Collection() .Connection(PersonWithSpouseConnectionClass.GetConnectionName()) .StoredProcedure("[PersonBoundedContext].[pPerson_Get]") .QueryParameters(queryParameters) .Parameters(p => p.Name("count").Count()) .ExecuteAsync(); return(result.Count, result.Records); }
public Person GetMarriedToForPerson(int personId) { var result = Query <Person> .Single() .Connection(PersonWithSpouseConnectionClass.GetConnectionName()) .StoredProcedure("[PersonBoundedContext].[pPerson_GetMarriedTo]") .Parameters( p => p.Name("personId").Value(personId) ) .Execute(); return(result.Record); }
public async override Task <Person> GetByIdAsync(int personId) { var result = await Query <Person> .Single() .Connection(PersonWithSpouseConnectionClass.GetConnectionName()) .StoredProcedure("[PersonBoundedContext].[pPerson_GetById]") .Parameters( p => p.Name("personId").Value(personId) ) .ExecuteAsync(); 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(PersonWithSpouseConnectionClass.GetConnectionName()) .StoredProcedure("[PersonBoundedContext].[pPerson_Insert]") .Parameters( p => p.Name("name").Value(entity.Name), p => p.Name("gender").Value(entity.Gender), p => p.Name("createdBy").Value(entity.CreatedBy) ) .OnBeforeCommandExecuted(cmd => { var dependencies = Dependencies(); var spouseDependency = (Person)dependencies?.SingleOrDefault()?.Entity; if (spouseDependency != null) { entity.SpouseId = spouseDependency.Id; } cmd.Parameters( p => p.Name("spouseId").Value(entity.SpouseId) ); }) .RecordInstance(entity) .MapProperties( p => p.Name("Id").Index(0) ); return(command); }
protected override Command CreateUpdateCommand(Person entity, IAuthenticatedUser user, string selector) { if (user != null) { entity.UpdatedBy = (int)user.Id; } return(Command .NonQuery() .Connection(PersonWithSpouseConnectionClass.GetConnectionName()) .StoredProcedure("[PersonBoundedContext].[pPerson_Update]") .Parameters( p => p.Name("name").Value(entity.Name), p => p.Name("gender").Value(entity.Gender), p => p.Name("updatedBy").Value(entity.UpdatedBy) ) .OnBeforeCommandExecuted(cmd => { var dependencies = Dependencies(); cmd.Parameters( p => p.Name("personId").Value(entity.Id) ); var entityForMarriedTo = (Person)dependencies.SingleOrDefault(d => d.Selector == "MarriedTo")?.Entity; if (entityForMarriedTo != null) { entity.SpouseId = entityForMarriedTo.Id; } cmd.Parameters( p => p.Name("spouseId").Value(entity.SpouseId) ); })); }
public SavePersonCommandAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(PersonWithSpouseConnectionClass.GetConnectionName())) { }
public SavePersonCommandAggregate(PersonInputDto person, EntityDependency[] dependencies = null) : base(new DomainFramework.DataAccess.RepositoryContext(PersonWithSpouseConnectionClass.GetConnectionName())) { Initialize(person, dependencies); }