コード例 #1
0
        public void CanRT_Compendium()
        {
            //var creator = new BeingCreator(__factory);
            var publisher      = new BookPublisher(_creator);
            var tomeOfChaos    = publisher.Tome_FromNew("gloop");
            var herbal         = new Herbal();
            var socialRegister = new SocialRegister(_creator);
            var dramaticon     = new Dramaticon();
            var atlas          = new Atlas();

            var idGen      = new IDGenerator(33);
            var compendium = new Compendium(idGen, _creator, tomeOfChaos, herbal, socialRegister, dramaticon, atlas);

            var yaml = _serializer.Serialize(compendium);

            Assert.That(yaml, Is.Not.Null);

            var newBook = _deserializer.Deserialize <IBook>(yaml);

            Assert.That(newBook, Is.TypeOf <Compendium>());
            var newCompendium = (Compendium)newBook;

            Assert.That(newCompendium.IDGenerator.UseID(), Is.EqualTo(33));
            Assert.That(newCompendium.TomeOfChaos.TopSeed, Is.EqualTo("gloop"));

            //TODO: slightly more muscular checks once these books go beyond placeholders
            Assert.That(newCompendium.Herbal, Is.Not.Null);
            Assert.That(newCompendium.SocialRegister, Is.Not.Null);
            Assert.That(newCompendium.Dramaticon, Is.Not.Null);
            Assert.That(newCompendium.Atlas, Is.Not.Null);
        }
コード例 #2
0
        public BookPublisher Create(BookPublisher BookPublisher)
        {
            var result = _context.Add <BookPublisher>(BookPublisher);

            _context.SaveChanges();
            return(result.Entity);
        }
コード例 #3
0
        public BookPublisher Delete(BookPublisher BookPublisher)
        {
            var result = _context.Remove(BookPublisher);

            _context.SaveChanges();
            return(result.Entity);
        }
コード例 #4
0
        public void Execute(BookInsertDto request)
        {
            var book = new Book
            {
                Title      = request.Title,
                CategoryId = request.CategoryId,
                Image      = new Image {
                    Src = request.Src
                }
            };

            var bookpublisher = new BookPublisher
            {
                Price       = request.Price,
                PublisherId = request.PublisherId,
                Book        = book
            };

            var bookauthor = new BookAuthor
            {
                Book     = book,
                AuthorId = request.AuthorId
            };

            book.BookPublishers.Add(bookpublisher);
            book.BookAuthors.Add(bookauthor);

            _context.Books.Add(book);

            _context.SaveChanges();
        }
コード例 #5
0
        public BookPublisher Post(BookPublisherDTO value)
        {
            BookPublisher model = new BookPublisher()
            {
                BookId      = value.BookId,
                PublisherId = value.PublisherId
            };

            return(IBookPublisherRepository.Create(model));
        }
コード例 #6
0
        public void SetUp()
        {
            var   publisher = new BookPublisher(null);
            Atlas atlas     = publisher.Atlas_FromNew();

            //var creator = new BeingCreator(__factory);
            //var ycb = new YConv_IBeing { BeingCreator = creator };
            _loader = new MapLoader(__log, atlas);
            Basis.ConnectIDGenerator();
        }
コード例 #7
0
 public bool Insert(BookPublisher publisher)
 {
     try
     {
         db.BookPublishers.Add(publisher);
         db.SaveChanges();
         return(db.BookPublishers.Count(_ => _.Name == publisher.Name) > 0);
     }
     catch
     {
         return(false);
     }
 }
コード例 #8
0
ファイル: BookPublisherTest.cs プロジェクト: SoloJr/ASSE
        public void TestBookPublisherCreateWithObjectNotId()
        {
            var publisher = new Publisher
            {
                Name         = "Editura Pentru Copii",
                FoundingDate = new DateTime(2000, 1, 1),
                Headquarter  = "Romania",
                Id           = 1
            };

            var book = new Book()
            {
                Id       = 1,
                Language = "Romanian",
                Name     = "Amintiri din Copilarie",
                Year     = 1885,
                Authors  = new List <Author>
                {
                    new Author()
                }
            };

            var bookPublisherId = 1;
            var bookPublisher   = new BookPublisher
            {
                Id          = bookPublisherId,
                RentCount   = 200,
                Pages       = 200,
                Type        = BookType.Hardback,
                Book        = book,
                BookId      = book.Id,
                Publisher   = publisher,
                PublisherId = publisher.Id,
                ReleaseDate = new DateTime(2020, 12, 31),
                ForLecture  = 10,
                ForRent     = 10
            };

            book.Publishers.Add(bookPublisher);

            var result = this.validator.Validate(bookPublisher);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.IsValid, true);
            Assert.AreEqual(result.Errors.Count, 0);
            Assert.IsTrue(book.Publishers.Count > 0);
            Assert.IsNotNull(bookPublisher.Book);
            Assert.IsNotNull(bookPublisher.Publisher);
            Assert.IsTrue(bookPublisherId == bookPublisher.Id);
        }
コード例 #9
0
        private void AddRelationshipsBookPublisher(Book book, List <GetPublisherViewItem> publishers)
        {
            List <BookPublisher> bookPublishers = new List <BookPublisher>();

            foreach (var publisher in publishers)
            {
                var bookPublisher = new BookPublisher();
                bookPublisher.BookId      = book.Id;
                bookPublisher.PublisherId = publisher.Id;
                bookPublishers.Add(bookPublisher);
            }

            _bookPublisherRepository.Add(bookPublishers);
        }
コード例 #10
0
        public BookPublisher Put(int id, BookPublisherDTO value)
        {
            BookPublisher model = IBookPublisherRepository.Get(id);

            if (value.BookId != 0)
            {
                model.BookId = value.BookId;
            }
            if (value.PublisherId != 0)
            {
                model.PublisherId = value.PublisherId;
            }
            return(IBookPublisherRepository.Update(model));
        }
コード例 #11
0
 public void Init()
 {
     Injector.Inject(new MockBindings());
     this.bookPublisher = new BookPublisher
     {
         BookId      = 1,
         RentCount   = 10,
         Pages       = 200,
         PublisherId = 1,
         ReleaseDate = DateTime.MaxValue,
         Type        = BookType.Ebook,
         ForLecture  = 10,
         ForRent     = 4
     };
 }
コード例 #12
0
 public bool Update(BookPublisher publisher)
 {
     try
     {
         BookPublisher pu = db.BookPublishers.Find(publisher.ID);
         pu.Name        = publisher.Name;
         pu.Address     = publisher.Address;
         pu.PhoneNumber = publisher.PhoneNumber;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #13
0
        public void TestCreateReaderSuccessBookWithObjects()
        {
            var reader = new Reader
            {
                Info = new PersonalInfo
                {
                    PhoneNumber = "0731233233",
                    Email       = "*****@*****.**"
                },
                Address   = "0",
                FirstName = "Mircea",
                LastName  = "Solovastru",
                Id        = 1
            };

            var book = new BookPublisher()
            {
                ForRent     = 120,
                RentCount   = 100,
                Pages       = 240,
                PublisherId = 1,
                BookId      = 1,
                ReleaseDate = DateTime.Now,
                Type        = BookType.Hardback,
                Id          = 1
            };

            var readerBook = new ReaderBook
            {
                LoanDate        = DateTime.Now,
                DueDate         = DateTime.Now.AddDays(14),
                BookPublisherId = book.Id,
                ReaderId        = reader.Id,
                Id            = 1,
                BookPublisher = book,
                Reader        = reader,
                ExtensionDays = 0
            };

            var result = this.validator.Validate(readerBook);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.IsValid);
            Assert.IsTrue(result.Errors.Count == 0);
            Assert.IsNotNull(readerBook.BookPublisher);
            Assert.IsNotNull(readerBook.Reader);
        }
コード例 #14
0
 public bool Delete(long?id)
 {
     try
     {
         BookPublisher publisher = db.BookPublishers.Find(id);
         if (publisher == null)
         {
             return(false);
         }
         db.BookPublishers.Remove(publisher);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #15
0
 public ActionResult Edit(BookPublisher publisher)
 {
     if (ModelState.IsValid)
     {
         bool success = new PublisherDAO().Update(publisher);
         if (success)
         {
             SetAlert("Cập nhật nhà xuất bản thành công", "success");
             return(RedirectToAction("Index", "Publisher"));
         }
         else
         {
             SetAlert("Cập nhật  nhà xuất bản thất bại", "warning");
             ModelState.AddModelError("", "Cập nhật  nhà xuất bản không thành công");
         }
     }
     return(RedirectToAction("Index", "Publisher"));
 }
コード例 #16
0
 public ActionResult Create(BookPublisher publisher)
 {
     if (ModelState.IsValid)
     {
         PublisherDAO dao     = new PublisherDAO();
         bool         success = dao.Insert(publisher);
         if (success)
         {
             SetAlert("Thêm nhà xuất bản thành công", "success");
             return(RedirectToAction("Index", "Publisher"));
         }
         else
         {
             SetAlert("Thêm nhà xuất bản thất bại", "warning");
             ModelState.AddModelError("", "Thêm nhà xuất bản không thành công");
         }
     }
     return(RedirectToAction("Index", "Publisher"));
 }
コード例 #17
0
        public bool AddPublisher(AddPublishersCreate model)
        {
            foreach (int publisherId in model.Publishers)
            {
                var entity = new BookPublisher()
                {
                    BookId      = model.BookId,
                    PublisherId = publisherId
                };

                using (var ctx = new ApplicationDbContext())
                {
                    ctx.BookPublishers.Add(entity);
                    var changes = ctx.SaveChanges();
                }
            }

            return(true);
        }
コード例 #18
0
ファイル: BookPublisherTest.cs プロジェクト: SoloJr/ASSE
        public void TestBookPublisherFailWithoutType()
        {
            var bookPublisher = new BookPublisher
            {
                Id          = 1,
                Pages       = 100,
                ReleaseDate = DateTime.Now,
                RentCount   = 10,
                ForRent     = 10,
                ForLecture  = 10,
                BookId      = 1,
                PublisherId = 1
            };

            var result = this.validator.Validate(bookPublisher);

            Assert.IsNotNull(result);
            Assert.IsFalse(result.IsValid);
            Assert.IsFalse(result.Errors.Count == 0);
        }
コード例 #19
0
ファイル: BookPublisherTest.cs プロジェクト: SoloJr/ASSE
        public void TestBookPublisherFailWithoutPages()
        {
            var bookPublisher = new BookPublisher
            {
                Id          = 1,
                Pages       = 100,
                Type        = BookType.Hardback,
                RentCount   = 10,
                ForRent     = 10,
                ForLecture  = 10,
                BookId      = 1,
                PublisherId = 1
            };

            var result = this.validator.Validate(bookPublisher);

            Assert.IsNotNull(result);
            Assert.IsFalse(result.IsValid);
            Assert.IsFalse(result.Errors.Count == 0);
        }
コード例 #20
0
        public bool RemoveBook(AddBooksCreate model)
        {
            foreach (int bookId in model.Books)
            {
                var entity = new BookPublisher()
                {
                    BookId      = bookId,
                    PublisherId = model.PublisherId
                };

                using (var ctx = new ApplicationDbContext())
                {
                    ctx.BookPublishers.Attach(entity);
                    ctx.BookPublishers.Remove(entity);
                    var changes = ctx.SaveChanges();
                }
            }

            return(true);
        }
コード例 #21
0
        public static bool Open(BookPublisher dataObject)
        {
            if (dataObject == null)
            {
                throw new ArgumentNullException("dataObject");
            }

            var dialog = new BookPublisherEditorWindow()
            {
                DataContext           = dataObject,
                Owner                 = Registry.Get <MainWindow>(),
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                Title                 = (dataObject.Id <= 0)
                    ? "Book Manager - New Book Publisher"
                    : String.Format("Book Manager - Book Publisher Edit {0}", dataObject.Id)
            };

            dialog.ShowDialog();

            return(dialog.DialogResult.GetValueOrDefault());
        }
コード例 #22
0
        public void Post(BookDTO value)
        {
            Book model = new Book()
            {
                Name            = value.Name,
                Popularity      = value.Popularity,
                PublicationYear = value.PublicationYear
            };

            IBookRepository.Create(model);
            for (int i = 0; i < value.WriterId.Count; i++)
            {
                BookWriter BookWriter = new BookWriter()
                {
                    BookId   = model.Id,
                    WriterId = value.WriterId[i]
                };
                IBookWriterRepository.Create(BookWriter);
            }

            for (int i = 0; i < value.LibraryId.Count; i++)
            {
                BookLibrary BookLibrary = new BookLibrary()
                {
                    BookId    = model.Id,
                    LibraryId = value.LibraryId[i]
                };
                IBookLibraryRepository.Create(BookLibrary);
            }

            for (int i = 0; i < value.PublisherId.Count; i++)
            {
                BookPublisher BookPublisher = new BookPublisher()
                {
                    BookId      = model.Id,
                    PublisherId = value.PublisherId[i]
                };
                IBookPublisherRepository.Create(BookPublisher);
            }
        }
コード例 #23
0
ファイル: BookTest.cs プロジェクト: SoloJr/ASSE
        public void TestBookWithPublishers()
        {
            var publisher = new Publisher
            {
                Name         = "Editura Pentru Copii",
                FoundingDate = new DateTime(2000, 1, 1),
                Headquarter  = "Romania",
                Id           = 1
            };

            var book = new Book()
            {
                Language = "Romanian",
                Name     = "Amintiri din Copilarie",
                Year     = 1885,
                Authors  = new List <Author>
                {
                    new Author()
                }
            };

            var bookPublisher = new BookPublisher
            {
                BookId      = book.Id,
                PublisherId = publisher.Id,
                RentCount   = 200,
                Pages       = 200
            };

            book.Publishers.Add(bookPublisher);

            var result = this.validator.Validate(book);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.IsValid, true);
            Assert.AreEqual(result.Errors.Count, 0);
            Assert.IsTrue(book.Publishers.Count > 0);
        }
コード例 #24
0
        public void CanRT_TomeOfChaos()
        {
            var publisher = new BookPublisher(_creator);
            var tome      = publisher.Tome_FromNew("floop");
            var yaml      = _serializer.Serialize(tome);

            Assert.That(yaml, Is.Not.Null);

            var newBook = _deserializer.Deserialize <IBook>(yaml);

            Assert.That(newBook, Is.TypeOf <TomeOfChaos>());
            var newTome = (TomeOfChaos)newBook;

            Assert.That(newTome.TopSeed, Is.EqualTo("floop"));
            Assert.That(newTome.Generators["Top"], Is.TypeOf <NR3Generator>());
            Assert.That(newTome.Generators["Learnable"], Is.TypeOf <NR3Generator>());
            Assert.That(newTome.Generators["MapTop"], Is.TypeOf <NR3Generator>());

            for (int i = 0; i < 10; i++)
            {
                Assert.That(newTome.LearnableRndNext(), Is.EqualTo(tome.LearnableRndNext()),
                            "The numbers emitted from a serialized & deserialized RNG should match the RNG it was originally serialized from.");
            }
        }
コード例 #25
0
 public void SetUp()
 {
     _publisher = SourceMe.The <BookPublisher>();
 }
コード例 #26
0
 /// <summary>
 /// Compares two entities and detects, if they are the same or not.
 /// </summary>
 /// <param name="a">A source entity (an entity in this collection).</param>
 /// <param name="b">A target entity (an entity in the other collection).</param>
 /// <returns>True if both entities are the same.</returns>
 public bool NeedsUpdate(BookPublisher a, BookPublisher b)
 {
     return(a.NeedsUpdate(b));
 }
コード例 #27
0
 /// <summary>
 /// Compares two entities and returns their natural order.
 /// </summary>
 /// <param name="a">A source entity (an entity in this collection).</param>
 /// <param name="b">A target entity (an entity in the other collection).</param>
 /// <returns>-1, 0, 1.</returns>
 public int GetOrder(BookPublisher a, BookPublisher b)
 {
     return(a.Id.CompareTo(b.Id));
 }
コード例 #28
0
 public void DeleteBookPublisher(BookPublisher obj)
 {
     Registry.Get <BookPublisherDataLayer>().Delete(obj);
 }
コード例 #29
0
 public void SaveBookPublisher(BookPublisher obj)
 {
     Registry.Get <BookPublisherDataLayer>().Save(obj);
 }
コード例 #30
0
        public BookPublisher Delete(int id)
        {
            BookPublisher BookPublisher = IBookPublisherRepository.Get(id);

            return(IBookPublisherRepository.Delete(BookPublisher));
        }