public IHttpActionResult Create(BookPostRep resource) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } try { var @event = new BookCreateEvent { Name = resource.Name, AuthorId = resource.AuthorId, CategoryId = resource.CategoryId }; this._bookService.Add(@event); return(this.CreatedAtRoute(BookResourceNames.Routes.GetById, new { id = @event.Id }, resource)); } catch (Exception ex) { return(this.InternalServerError(ex)); } }
public void HandleEvent(BookCreateEvent e) { this.AggregateRootId = e.AggregateRootId; this.Title = e.Title; this.Author = e.Author; this.Description = e.Description; this.ISBN = e.ISBN; this.Pages = e.Pages; this.Inventory = e.Inventory; }
public void Add(BookCreateEvent @event) { var entity = new Book(); entity = this.CreateOrUpdate(@event, entity); entity.Id = Guid.NewGuid(); this._bookEntityService.Add(entity); this._bookEntityService.Save(); @event.Id = entity.Id; }
private void HandleEvent(BookCreateEvent domainEvent) { using (QueryDBEntities _dbContext = new QueryDBEntities()) { Book book = new Book { AggregateRootId = domainEvent.AggregateRootId, Title = domainEvent.Title, Author = domainEvent.Author, Description = domainEvent.Description, ISBN = domainEvent.ISBN, Pages = domainEvent.Pages, Inventory = domainEvent.Inventory }; _dbContext.Book.Add(book); _dbContext.SaveChanges(); } }