Пример #1
0
        public void DeletePerson(Guid personId)
        {
            Persistence.BeginTransaction();

            var person = Persistence.GetById <Person>(personId);

            Persistence.Delete(person);

            Persistence.Commit();
        }
Пример #2
0
        public void AddBookToBookGroup(Guid bookGroupId, Book book)
        {
            Persistence.BeginTransaction();

            var bookGroup = Persistence.GetById <BookGroup>(bookGroupId);

            bookGroup.AddBook(book);

            Persistence.Update(bookGroup);
            Persistence.Commit();
        }
Пример #3
0
        public void UpdateBookGroup(UpdateBookGroupRequest request)
        {
            Persistence.BeginTransaction();

            var bookGroup = Persistence.GetById <BookGroup>(request.BookGroupId);

            bookGroup.Update(request);

            Persistence.Update(bookGroup);
            Persistence.Commit();
        }
Пример #4
0
        public void CreateBookGroup(CreateBookGroupRequest request, Book book)
        {
            Persistence.BeginTransaction();

            var bookGroup = new BookGroup(request);

            bookGroup.AddBook(book);

            Persistence.Create(bookGroup);
            Persistence.Commit();
        }
Пример #5
0
        public Person CreatePerson()
        {
            Persistence.BeginTransaction();

            var person = new Person();

            Persistence.Create(person);

            Persistence.Commit();

            return(person);
        }
Пример #6
0
        public void UpdateAuthor(UpdateAuthorRequest request)
        {
            if (!new UpdateAuthorRequestValidator().Validate(request).IsValid)
            {
                throw new Exception("UpdateAuthor validation error");
            }

            Persistence.BeginTransaction();
            var author = GetAuthorById(request.Id);

            author.Update(request);
            Persistence.Commit();
        }
Пример #7
0
        public void UpdateBook(UpdateBookRequest request)
        {
            Persistence.BeginTransaction();
            if (!new UpdateBookRequestValidator().Validate(request).IsValid)
            {
                throw new Exception("UpdateBook validation error");
            }

            var book = GetBookById(request.Id);

            book.Update(request);
            Persistence.Commit();
        }
Пример #8
0
        public Guid CreateAuthor(CreateAuthorRequest request)
        {
            if (!new CreateAuthorRequestValidator().Validate(request).IsValid)
            {
                throw new Exception("CreateAuthor validation error");
            }

            Persistence.BeginTransaction();
            var author = new Author(request);

            Persistence.Create(author);
            Persistence.Commit();
            return(author.Id);
        }
Пример #9
0
        public Guid CreateBook(CreateBookRequest request)
        {
            if (!new CreateBookRequestValidator().Validate(request).IsValid)
            {
                throw new Exception("CreateBook validation error");
            }

            Persistence.BeginTransaction();

            var book = new Book(request);

            Persistence.Create(book);
            Persistence.Commit();
            return(book.Id);
        }
Пример #10
0
        public async Task RemoveFromOwnedBooks(Book book)
        {
            Persistence.BeginTransaction();

            var person = GetCurrentPerson();

            if (!person.OwnedBooks.Any(b => b.Id == book.Id))
            {
                //Person already has this book on his WishList
                return;
            }
            person.OwnedBooks.Remove(book);

            await Persistence.Update(person);

            await Persistence.Commit();
        }