Esempio n. 1
0
 public int Create(PeriodicalEdition periodicalEdition)
 {
     periodicalEdition.Periodical = context.Periodicals.Find(periodicalEdition.Periodical.Id);
     context.PeriodicalEditions.Add(periodicalEdition);
     context.SaveChanges();
     return(periodicalEdition.Id);
 }
Esempio n. 2
0
 public int Create(PublishedBook pBook)
 {
     pBook.Book            = context.Books.Find(pBook.Book.Id);
     pBook.PublishingHouse = context.PublishingHouses.Find(pBook.PublishingHouse.Id);
     context.PublishedBooks.Add(pBook);
     context.SaveChanges();
     return(pBook.Id);
 }
Esempio n. 3
0
        public int Create(Brochure brochure)
        {
            brochure.PublishingHouse = context.PublishingHouses.Find(brochure.PublishingHouse.Id);
            context.Brochures.Add(brochure);

            context.SaveChanges();
            return(brochure.Id);
        }
Esempio n. 4
0
        public int Create(Book book, IEnumerable <AuthorInBook> authorInBookList = null)
        {
            context.Books.Add(book);

            if (authorInBookList != null && authorInBookList.Count() > 0)
            {
                IEnumerable <int>   bookAuthors = authorInBookList.Select(a => a.Id);
                IQueryable <Author> authors     = context.Authors.Where(x => bookAuthors.Contains(x.Id));

                foreach (Author author in authors)
                {
                    context.AuthorsInBooks.Add(new AuthorInBook
                    {
                        Author = author,
                        Book   = book
                    });
                }
            }

            context.SaveChanges();
            return(book.Id);
        }
 public void Save()
 {
     db.SaveChanges();
 }
 public int Create(PublishingHouse publishingHouse)
 {
     context.PublishingHouses.Add(publishingHouse);
     context.SaveChanges();
     return(publishingHouse.Id);
 }
Esempio n. 7
0
 public int Create(Author authtor)
 {
     context.Authors.Add(authtor);
     context.SaveChanges();
     return(authtor.Id);
 }
 public int Create(AuthorInBook ainb)
 {
     context.AuthorsInBooks.Add(ainb);
     context.SaveChanges();
     return(ainb.Id);
 }
 public int Create(Periodical periodical)
 {
     context.Periodicals.Add(periodical);
     context.SaveChanges();
     return(periodical.Id);
 }