Example #1
0
        public Book Add(Book book)
        {
            var addedBook = context.Add(book);

            context.SaveChanges();
            return(addedBook.Entity);
        }
Example #2
0
        public Author AuthorWithName(string name)
        {
            var author = context.Authors.Find(name);

            if (author == null)
            {
                var newAuthor = new Author(name);
                context.Add(newAuthor);
                context.SaveChanges();
                return(newAuthor);
            }
            else
            {
                return(author);
            }
        }