public async override Task <IEnumerable <Book> > GetAllAsync() { var result = await Query <Book> .Collection() .Connection(BookWithPagesConnectionClass.GetConnectionName()) .StoredProcedure("[BookBoundedContext].[pBook_GetAll]") .ExecuteAsync(); return(result.Records); }
public override IEnumerable <Page> GetAll() { var result = Query <Page> .Collection() .Connection(BookWithPagesConnectionClass.GetConnectionName()) .StoredProcedure("[BookBoundedContext].[pPage_GetAll]") .Execute(); return(result.Records); }
protected override Command CreateDeleteCommand(Page entity, IAuthenticatedUser user, string selector) { return(Command .NonQuery() .Connection(BookWithPagesConnectionClass.GetConnectionName()) .StoredProcedure("[BookBoundedContext].[pPage_Delete]") .Parameters( p => p.Name("pageId").Value(entity.Id) )); }
public async override Task <(int, IEnumerable <Book>)> GetAsync(CollectionQueryParameters queryParameters) { var result = await Query <Book> .Collection() .Connection(BookWithPagesConnectionClass.GetConnectionName()) .StoredProcedure("[BookBoundedContext].[pBook_Get]") .QueryParameters(queryParameters) .Parameters(p => p.Name("count").Count()) .ExecuteAsync(); return(result.Count, result.Records); }
public override (int, IEnumerable <Page>) Get(CollectionQueryParameters queryParameters) { var result = Query <Page> .Collection() .Connection(BookWithPagesConnectionClass.GetConnectionName()) .StoredProcedure("[BookBoundedContext].[pPage_Get]") .QueryParameters(queryParameters) .Parameters(p => p.Name("count").Count()) .Execute(); return(result.Count, result.Records); }
public async Task <Book> GetBookForPageAsync(int pageId) { var result = await Query <Book> .Single() .Connection(BookWithPagesConnectionClass.GetConnectionName()) .StoredProcedure("[BookBoundedContext].[pPage_GetBook]") .Parameters( p => p.Name("pageId").Value(pageId) ) .ExecuteAsync(); return(result.Record); }
public IEnumerable <Page> GetAllPagesForBook(int bookId) { var result = Query <Page> .Collection() .Connection(BookWithPagesConnectionClass.GetConnectionName()) .StoredProcedure("[BookBoundedContext].[pBook_GetAllPages]") .Parameters( p => p.Name("bookId").Value(bookId) ) .Execute(); return(result.Records); }
public async Task <Book> GetBookByTitleAsync(string title) { var result = await Query <Book> .Single() .Connection(BookWithPagesConnectionClass.GetConnectionName()) .StoredProcedure("[BookBoundedContext].[pBook_GetByTitle]") .Parameters( p => p.Name("title").Value(title) ) .ExecuteAsync(); return(result.Record); }
public override Book GetById(int bookId) { var result = Query <Book> .Single() .Connection(BookWithPagesConnectionClass.GetConnectionName()) .StoredProcedure("[BookBoundedContext].[pBook_GetById]") .Parameters( p => p.Name("bookId").Value(bookId) ) .Execute(); return(result.Record); }
protected override Command CreateInsertCommand(Book entity, IAuthenticatedUser user, string selector) { if (user != null) { entity.CreatedBy = (int)user.Id; } var command = Command .NonQuery() .Connection(BookWithPagesConnectionClass.GetConnectionName()) .StoredProcedure("[BookBoundedContext].[pBook_Insert]") .Parameters( //p => p.Set("title", entity.Title), //p => p.Name("category").Value(entity.Category), //p => p.Name("datePublished").Value(entity.DatePublished), //p => p.Name("publisherId").Value(entity.PublisherId), //p => p.Name("isHardCopy").Value(entity.IsHardCopy), //p => p.Name("createdBy").Value(entity.CreatedBy), p => p.Name("bookId").SqlType((int)SqlDbType.Int).IsOutput() ) .AutoGenerateParameters(excludedProperties: new Expression <Func <Book, object> >[] { m => m.Id, m => m.CreatedDateTime, m => m.UpdatedBy, m => m.UpdatedDateTime }) .RecordInstance(entity) //.MapProperties( // p => p.Name("Id").Index(0) //) .MapOutputParameters( map => map.Name("bookId").Property <Book>(b => b.Id) ) //.OnAfterCommandExecuted(cmd => // entity.Id = (int)cmd.Parameters // .Where(p => // p.Direction == System.Data.ParameterDirection.Output && // p.Name == "bookId" // ) // .Single().Value //) ; return(command); }
protected override Command CreateUpdateCommand(Page entity, IAuthenticatedUser user, string selector) { if (user != null) { entity.UpdatedBy = (int)user.Id; } return(Command .NonQuery() .Connection(BookWithPagesConnectionClass.GetConnectionName()) .StoredProcedure("[BookBoundedContext].[pPage_Update]") .Parameters( p => p.Name("pageId").Value(entity.Id), p => p.Name("index").Value(entity.Index), p => p.Name("updatedBy").Value(entity.UpdatedBy), p => p.Name("bookId").Value(entity.BookId) )); }
protected override Command CreateUpdateCommand(Book entity, IAuthenticatedUser user, string selector) { if (user != null) { entity.UpdatedBy = (int)user.Id; } return(Command .NonQuery() .Connection(BookWithPagesConnectionClass.GetConnectionName()) .StoredProcedure("[BookBoundedContext].[pBook_Update]") .Parameters( p => p.Name("bookId").Value(entity.Id), p => p.Name("title").Value(entity.Title), p => p.Name("category").Value(entity.Category), p => p.Name("datePublished").Value(entity.DatePublished), p => p.Name("publisherId").Value(entity.PublisherId), p => p.Name("isHardCopy").Value(entity.IsHardCopy), p => p.Name("updatedBy").Value(entity.UpdatedBy) )); }
protected override Command CreateInsertCommand(Page entity, IAuthenticatedUser user, string selector) { if (user != null) { entity.CreatedBy = (int)user.Id; } var command = Query <Page> .Single() .Connection(BookWithPagesConnectionClass.GetConnectionName()) .StoredProcedure("[BookBoundedContext].[pPage_Insert]") .Parameters( p => p.Name("index").Value(entity.Index), p => p.Name("createdBy").Value(entity.CreatedBy) ) .OnBeforeCommandExecuted(cmd => { var dependencies = Dependencies(); var bookDependency = (Book)dependencies?.SingleOrDefault()?.Entity; if (bookDependency != null) { entity.BookId = bookDependency.Id; } cmd.Parameters( p => p.Name("bookId").Value(entity.BookId) ); }) .RecordInstance(entity) .MapProperties( p => p.Name("Id").Index(0) ); return(command); }
public CreatePageCommandAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(BookWithPagesConnectionClass.GetConnectionName())) { }
public CreatePageCommandAggregate(SavePageInputDto page, EntityDependency[] dependencies = null) : base(new DomainFramework.DataAccess.RepositoryContext(BookWithPagesConnectionClass.GetConnectionName())) { Initialize(page, dependencies); }
public GetBookByTitleQueryAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(BookWithPagesConnectionClass.GetConnectionName())) { var context = (DomainFramework.DataAccess.RepositoryContext)RepositoryContext; BookQueryRepository.Register(context); PageQueryRepository.Register(context); GetAllPagesLinkedAggregateQueryOperation = new GetAllLinkedAggregateQueryCollectionOperation <int, Page, PageOutputDto> { GetAllLinkedEntities = (repository, entity, user) => ((PageQueryRepository)repository).GetAllPagesForBook(RootEntity.Id).ToList(), GetAllLinkedEntitiesAsync = async(repository, entity, user) => { var entities = await((PageQueryRepository)repository).GetAllPagesForBookAsync(RootEntity.Id); return(entities.ToList()); }, CreateLinkedQueryAggregate = entity => { if (entity is Page) { return(new GetPageByIdQueryAggregate()); } else { throw new InvalidOperationException(); } } }; QueryOperations.Enqueue(GetAllPagesLinkedAggregateQueryOperation); }
public GetBooksQueryAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(BookWithPagesConnectionClass.GetConnectionName())) { var context = (DomainFramework.DataAccess.RepositoryContext)RepositoryContext; BookQueryRepository.Register(context); PageQueryRepository.Register(context); }
public DeleteBookCommandAggregate(DeleteBookInputDto book, EntityDependency[] dependencies = null) : base(new DomainFramework.DataAccess.RepositoryContext(BookWithPagesConnectionClass.GetConnectionName())) { Initialize(book, dependencies); }