protected override Command CreateDeleteCommand(Person entity, IAuthenticatedUser user, string selector) { return(Command .NonQuery() .Connection(PersonWithDisciplesConnectionClass.GetConnectionName()) .StoredProcedure("[PersonBoundedContext].[pPerson_Delete]") .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(PersonWithDisciplesConnectionClass.GetConnectionName()) .StoredProcedure("[PersonBoundedContext].[pPerson_Get]") .QueryParameters(queryParameters) .Parameters(p => p.Name("count").Count()) .ExecuteAsync(); return(result.Count, result.Records); }
public IEnumerable <Person> GetAllDisciplesForPerson(int personId) { var result = Query <Person> .Collection() .Connection(PersonWithDisciplesConnectionClass.GetConnectionName()) .StoredProcedure("[PersonBoundedContext].[pPerson_GetAllDisciples]") .Parameters( p => p.Name("personId").Value(personId) ) .Execute(); return(result.Records); }
public async override Task <Person> GetByIdAsync(int personId) { var result = await Query <Person> .Single() .Connection(PersonWithDisciplesConnectionClass.GetConnectionName()) .StoredProcedure("[PersonBoundedContext].[pPerson_GetById]") .Parameters( p => p.Name("personId").Value(personId) ) .ExecuteAsync(); return(result.Record); }
protected override Command CreateUpdateCommand(Person entity, IAuthenticatedUser user, string selector) { if (user != null) { entity.UpdatedBy = (int)user.Id; } return(Command .NonQuery() .Connection(PersonWithDisciplesConnectionClass.GetConnectionName()) .StoredProcedure("[PersonBoundedContext].[pPerson_Update]") .Parameters( p => p.Name("personId").Value(entity.Id), p => p.Name("name").Value(entity.Name), p => p.Name("gender").Value(entity.Gender), p => p.Name("updatedBy").Value(entity.UpdatedBy), p => p.Name("leaderId").Value(entity.LeaderId) )); }
protected override Command CreateInsertCommand(Person entity, IAuthenticatedUser user, string selector) { if (user != null) { entity.CreatedBy = (int)user.Id; } var command = Query <Person> .Single() .Connection(PersonWithDisciplesConnectionClass.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 leaderDependency = (Person)dependencies?.SingleOrDefault()?.Entity; if (leaderDependency != null) { entity.LeaderId = leaderDependency.Id; } cmd.Parameters( p => p.Name("leaderId").Value(entity.LeaderId) ); }) .RecordInstance(entity) .MapProperties( p => p.Name("Id").Index(0) ); return(command); }
public SavePersonCommandAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(PersonWithDisciplesConnectionClass.GetConnectionName())) { }
public SavePersonCommandAggregate(PersonInputDto person, EntityDependency[] dependencies = null) : base(new DomainFramework.DataAccess.RepositoryContext(PersonWithDisciplesConnectionClass.GetConnectionName())) { Initialize(person, dependencies); }