// TODO - Should only return the Id public String Create(CreateBookDto createBookDto) { var genre = _session.Query<Genre>().Where(g => g.Id == createBookDto.Genre).Single(); var book = new Book(createBookDto.Title, createBookDto.Authors, createBookDto.Description, genre, createBookDto.Status, createBookDto.Image); _session.Store(book); return book.Id; }
public static Book GetBookFromSessionFor(CreateBookDto dto, IDocumentSession session) { // TODO - turn this into a RavenDB index return session.Query<Book>() .Where(b => b.Title == dto.Title) .Where(b => b.Genre.Id == dto.Genre) .Where(b => b.Review == dto.Description) .Where(b => b.Status == dto.Status) .Where(b => b.Authors.Any(a => a == dto.Authors.First())) .FirstOrDefault(); }
public FubuContinuation Post(CreateBookInputModel model) { var dto = new CreateBookDto { Title = model.Title, Authors = model.Authors.ToStrings(), Description = model.Description_BigText, Genre = model.Genre, Image = FileUploader.GetBytes(model.Image), Status = model.BookStatus }; // TODO - should only return the Id var id = bookCreater.Create(dto); var linkModel = new ViewBookLinkModel { Id = id }; return FubuContinuation.RedirectTo(linkModel); }