public EditPublisher(string publisherName)
 {
     InitializeComponent();
     _oldPublisherName     = publisherName;
     _publishers           = new PublisherRepository();
     PublisherNameBox.Text = publisherName;
 }
示例#2
0
 public BookEditForm(BookRepository bookRepository, AuthorRepository authorRepository, PublisherRepository publisherRepository)
 {
     InitializeComponent();
     BookRepository      = bookRepository;
     AuthorRepository    = authorRepository;
     PublisherRepository = publisherRepository;
 }
示例#3
0
        private async void mICreateNewSolutionInEditor_Click(object sender, RoutedEventArgs e)
        {
            var commonConfig = CommonConfiguration.Get();

            var repositoryPublisher = new PublisherRepository(_service);

            var publisherDefault = await repositoryPublisher.GetDefaultPublisherAsync();

            var newSolution = new Solution()
            {
                FriendlyName = string.Empty,
                UniqueName   = string.Empty,
                Version      = "1.0.0.0",
                PublisherId  = null,
            };

            if (publisherDefault != null)
            {
                newSolution.PublisherId = new Microsoft.Xrm.Sdk.EntityReference(publisherDefault.LogicalName, publisherDefault.Id)
                {
                    Name = publisherDefault.FriendlyName
                };
            }

            WindowHelper.OpenEntityEditor(_iWriteToOutput, _service, commonConfig, Solution.EntityLogicalName, newSolution);
        }
示例#4
0
        static void Main(string[] args)
        {
            var connection = ConnectionManager.GetConnection();

            /*2.Create a new console app named SummaryPublisherApp.Here print to console:
             * Number of rows from the Publisher table(Execute scalar) ===> not done
             * Top 10 publishers(Id, Name)(SQL Data Reader)*/
            PublisherRepository.getTopTen(connection);
            /*Number of books for each publisher (Publiher Name, Number of Books)*/
            PublisherRepository.NumberOfBooks(connection);
            /*The total price for books for a publisher*/
            PublisherRepository.BookCosts(connection);

            /*3. Number of books and publisher name ( Create a class NumberOfBooksPerPublisher { NoOfBooks, PublisherName }, load the information into a List<NumberOfBooksPerPublisher > )*/
            List <NumberOfBooksPerPublisher> List = new List <NumberOfBooksPerPublisher>();
            var NewList = PublisherRepository.NumberOfBooks(connection);

            PublisherRepository.getTopTen(connection);

            /*4. Load data from a table (author, books, etc.) into a list (List<Book> or List<Author) and serialize all lines from that table in xml and json into two files.
             * Example: books.xml and books.json*/
            /*a. books.xml serialisation - Nu cred ca am facut bine deloc*/
            List <Book> Book = new List <Book>();

            Book = BookRepository.LoadBook(connection);
            var book = SerializeObject(Book);
        }
 public EditPublisherForm(string selectedPublisher)
 {
     InitializeComponent();
     _selectedPublisher   = selectedPublisher;
     _publisherRepository = new PublisherRepository();
     LoadPublisherInfo();
 }
示例#6
0
        static void Main(string[] args)
        {
            IPublisherRepository pub = new PublisherRepository();

            Console.WriteLine($"Number of rows from the Publisher table {pub.NrOfRowsFromPublisher()}");

            Console.WriteLine();
            Console.WriteLine("Top 10 publishers");
            foreach (var top10Publisher in pub.GetTop10Publishers())
            {
                Console.WriteLine($"{top10Publisher.PublisherId} {top10Publisher.Name}");
            }

            Console.WriteLine();
            Console.WriteLine("Number of books for each publisher (Publiher Name, Number of Books)");
            foreach (var x in pub.AllBooksForEachPublisher())
            {
                Console.WriteLine($"{x.PublisherName} {x.NoOfBooks}");
            }

            Console.WriteLine();
            Console.WriteLine($"The total price for books for a publisher");
            Console.WriteLine($"Number of books and publisher name ( Create a class NumberOfBooksPerPublisher , load the information into a List<NumberOfBooksPerPublisher > )");
            foreach (var z in pub.TotalPriceForAllBooksForEachPublisher())
            {
                Console.WriteLine($"{z.PublisherName} {z.TotalPrice}");
            }
        }
        public PublisherMutation(PublisherRepository repo)
        {
            FieldAsync <PublisherType>(
                name: "createPublisher",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <PublisherTypeInput> >
            {
                Name = "publisher"
            }),
                resolve: async context =>
            {
                var publisher = context.GetArgument <Publisher>("publisher");
                return(await context.TryAsyncResolve(
                           async c => await repo.AddPublisher(publisher)
                           ));
            }
                );

            FieldAsync <PublisherType>(

                "deletePublisher",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> >
            {
                Name = "publisherId"
            }),
                resolve: async context =>
            {
                var id = context.GetArgument <string>("publisherId");
                return(await context.TryAsyncResolve(
                           async c => await repo.RemovePublisher(Guid.Parse((ReadOnlySpan <char>)id))
                           ));
            }
                );
        }
示例#8
0
        public EditBook(string bookName)
        {
            InitializeComponent();
            _books      = new BookRepository();
            _authors    = new AuthorRepository();
            _publishers = new PublisherRepository();
            _oldName    = bookName;
            foreach (var author in _authors.GetAuthorList().OrderBy(author => author.LastName))
            {
                AuthorComboBox.Items.Add(author);
            }

            foreach (var publisher in _publishers.GetPublisherList().OrderBy(publisher => publisher.Name))
            {
                PublisherComboBox.Items.Add(publisher);
            }

            foreach (var genre in Enum.GetValues(typeof(Genre)))
            {
                GenreComboBox.Items.Add(genre);
            }

            foreach (var book in _books.GetBooksList().OrderBy(book => book.Name))
            {
                if (book.Name == bookName)
                {
                    NameBox.Text           = book.Name;
                    AuthorComboBox.Text    = book.Author.ToString();
                    PublisherComboBox.Text = book.Publisher.ToString();
                    PagesBox.Text          = book.NumberOfPages.ToString();
                    NumberOfBooksBox.Text  = book.NumberOfBooks.ToString();
                    GenreComboBox.Text     = book.Genre.ToString();
                }
            }
        }
示例#9
0
文件: Program.cs 项目: AdinaGh/9tema2
 static void Main()
 {
     _publisherRepository = new PublisherRepository(ConnectionManager.GetConnection());
     _bookRepository      = new BookRepository(ConnectionManager.GetConnection());
     NumberOfRowsFromThePublisher();
     Top10Publishers();
     NumberOfBooksForEachPublisherAndPrice();
 }
        public async Task Publisher_inserted_to_database()
        {
            var publisher = await PublisherHelpers.CreateValidPublisher();

            var repository = new PublisherRepository(_fixture.Context);

            (await repository.ExistsAsync(publisher.Id)).Should().BeTrue();
        }
        public BooksController()
        {
            SalesContext context = new SalesContext();

            this.uowFactory          = new EntityFrameworkUnitOfWorkFactory(context);
            this.repository          = new BookRepository(context);
            this.PublisherRepository = new PublisherRepository(context);
        }
示例#12
0
 public BookService()
 {
     _bookRepository          = new BookRepository();
     _publisherRepository     = new PublisherRepository();
     _bookPublisherRepository = new BookPublisherRepository();
     _authorRepository        = new AuthorRepository();
     _bookAuthorRepository    = new BookAuthorRepository();
 }
示例#13
0
        static void Main(string[] args)
        {
            DeveloperRepository developerR = new DeveloperRepository();
            GameRepository      gameR      = new GameRepository();
            GenreRepository     genreR     = new GenreRepository();
            OrderRepository     orderR     = new OrderRepository();
            PublisherRepository publisherR = new PublisherRepository();

            Genre genre1 = new Genre()
            {
                Title = "genre1"
            };
            Genre genre2 = new Genre()
            {
                Title = "genre2"
            };
            Genre genre3 = new Genre()
            {
                Title = "genre3"
            };

            Publisher publisher1 = new Publisher()
            {
                Title = "publisher"
            };

            Developer developer1 = new Developer()
            {
                Title = "developer"
            };

            genreR.Create(genre1);
            genreR.Create(genre2);
            genreR.Create(genre3);

            publisherR.Create(publisher1);

            developerR.Create(developer1);

            genre1 = genreR.GetById(1);
            genre2 = genreR.GetById(2);
            genre3 = genreR.GetById(3);

            publisher1 = publisherR.GetById(1);

            developer1 = developerR.GetById(1);

            Game game1 = new Game()
            {
                Title = "game1", Developer = developer1, Publisher = publisher1, Genres = new List <Genre> {
                    genre1, genre2, genre3
                }, Discription = "AAA", ReleaseDate = DateTime.Now, Discount = 10, Price = 15
            };

            gameR.Create(game1);

            game1 = gameR.GetById(1);
        }
示例#14
0
        private Guid CreatePublisher()
        {
            var publisher           = new Publisher("Pearson");
            var publisherRepository = new PublisherRepository(GetContext());

            publisherRepository.Add(publisher);
            publisherRepository.SaveChanges();
            return(publisher.Id);
        }
示例#15
0
        static void Main(string[] args)
        {
            PublisherRepository PublisherRepository = new PublisherRepository();

            PublisherRepository.publishers("Select count([PublisherId]) from[Publisher]");
            //Select count([PublisherId]) from [Publisher]
            //List<Publisher> publishers = PublisherRepository.publishers("");
            Console.ReadLine();
        }
示例#16
0
 public void AddRefreshList()
 {
     AuthorRepository.GetAllAuthors().ForEach(x => authorsComboBox.Items.Add(x));
     PublisherRepository.GetAllPublishers().ForEach(x => publishersComboBox.Items.Add(x));
     foreach (var bookGenre in (BookGenre[])Enum.GetValues(typeof(BookGenre)))
     {
         genresComboBox.Items.Add(bookGenre);
     }
 }
示例#17
0
        public void CeShiTitle()
        {
            CeShiAggregate ce = new CeShiAggregate(Guid.NewGuid());

            ce.ChangeTitle("李锋");
            var c = ce.UncommittedEvents.Count();

            PublisherRepository.publisher(ce.UncommittedEvents);
            Assert.True(c > 0);
        }
示例#18
0
        public async Task GetPublisherTesT_1()
        {
            var conString = "Server=DESKTOP-RF07Q5U;Database=AspCoreBookApp;Trusted_Connection=True;MultipleActiveResultSets=true";

            IRepositoryContextFactory repositoryContextFactory = new RepositoryContextFactory();
            IPublisherRepository      publisherRepository      = new PublisherRepository(conString, repositoryContextFactory);
            var authorList = await publisherRepository.GetPublishers(0, 10);

            var ext = authorList.Records.ToList();
        }
示例#19
0
        public GameManager( GameRepository games, PublisherRepository publishers)
        {
            if (games == null || publishers == null)
            {
                throw (new NullReferenceException());
            }

            _publishers = publishers;
            _games = games;
        }
示例#20
0
 public MenuForm()
 {
     InitializeComponent();
     LibraryContext      = new LibraryContext();
     StudentRepository   = new StudentRepository(LibraryContext);
     BookRepository      = new BookRepository(LibraryContext);
     BookRentRepository  = new BookRentRepository(LibraryContext);
     AuthorRepository    = new AuthorRepository(LibraryContext);
     PublisherRepository = new PublisherRepository(LibraryContext);
 }
示例#21
0
 private void RefreshPublishersListBox()
 {
     _publisherRepository = new PublisherRepository();
     _bookRepository      = new BookRepository();
     PublishersListBox.Items.Clear();
     foreach (var book in _publisherRepository.GetAllPublishers())
     {
         PublishersListBox.Items.Add(book);
     }
 }
示例#22
0
 public Publishers()
 {
     InitializeComponent();
     _publishers = new PublisherRepository();
     _books      = new BookRepository();
     foreach (var publisher in _publishers.GetPublisherList().OrderBy(publisher => publisher.Name))
     {
         PublishersListBox.Items.Add(publisher.ToString());
     }
 }
示例#23
0
 public EntityService()
 {
     _bookService        = new BookRepository();
     _categoryService    = new CategoryRepository();
     _orderDetailService = new OrderDetailRepository();
     _orderService       = new OrderRepository();
     _publisherService   = new PublisherRepository();
     _roleService        = new RoleRepository();
     _webUserservice     = new WebUserRepository();
 }
示例#24
0
        public static IServiceCollection AddBookDbContextInitializer(this IServiceCollection services, IConfiguration config)
        {
            var connectionString = config.GetConnectionString("DefaultConnection");

            services.AddDbContext <BookDbContext>(config =>
            {
                //config.UseInMemoryDatabase("BookService");
                config.UseSqlServer(connectionString);
            });
            services.AddScoped <ILanguageRepository>(sp =>
            {
                var dbContext = sp.GetRequiredService <BookDbContext>();
                var logger    = sp.GetRequiredService <ILogger <LanguageRepositoryLoggingDecorator> >();

                var service = new LanguageRepository(dbContext);
                return(new LanguageRepositoryLoggingDecorator(service, logger));
            });

            services.AddScoped <IAuthorRepository>(sp =>
            {
                var dbContext = sp.GetRequiredService <BookDbContext>();
                var logger    = sp.GetRequiredService <ILogger <AuthorRepositoryLoggingDecorator> >();

                var service = new AuthorRepository(dbContext);
                return(new AuthorRepositoryLoggingDecorator(service, logger));
            });

            services.AddScoped <IPublisherRepository>(sp =>
            {
                var dbContext = sp.GetRequiredService <BookDbContext>();
                var logger    = sp.GetRequiredService <ILogger <PublisherRepositoryLoggingDecorator> >();

                var service = new PublisherRepository(dbContext);
                return(new PublisherRepositoryLoggingDecorator(service, logger));
            });


            services.AddScoped <ICategoryRepository>(sp =>
            {
                var dbContext = sp.GetRequiredService <BookDbContext>();
                var logger    = sp.GetRequiredService <ILogger <CategoryRepositoryLoggingDecorator> >();

                var service = new CategoryRepository(dbContext);
                return(new CategoryRepositoryLoggingDecorator(service, logger));
            });

            return(services.AddScoped <IBookRepository>(sp =>
            {
                var dbContext = sp.GetRequiredService <BookDbContext>();
                var logger = sp.GetRequiredService <ILogger <BookRepositoryLoggingDecorator> >();

                var service = new BookRepository(dbContext);
                return new BookRepositoryLoggingDecorator(service, logger);
            }));
        }
示例#25
0
        public override void OnRegister()
        {
            categoryRepository = Data as Repository<Category>;
            publisherRepository = new PublisherRepository();

            categories = categoryRepository.GetAll();
            foreach (var category in categories) {
                category.Publishers = publisherRepository.FindByCategory(category);
            }
            SendNotification(ApplicationFacade.InitCategory, categories);
        }
        public async Task TestPublisherRepo_Exists()
        {
            //Arrange
            PublisherRepository TestRepo = CreatePublisherTestRepo("PublisherExists");

            //Act
            var result = await TestRepo.Exist(_PublisherNumber - 1);  //Subtract one since it starts at 0

            //Assert
            Assert.IsTrue(result);
        }
示例#27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnitOfWork" /> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public UnitOfWork(AppDbContext context)
 {
     _context     = context;
     Authors      = new AuthorRepository(_context);
     BookBorrows  = new BookBorrowRepository(_context);
     BookEditions = new BookEditionRepository(_context);
     Books        = new BookRepository(_context);
     Domains      = new DomainRepository(_context);
     Publishers   = new PublisherRepository(_context);
     Users        = new UserRepository(_context);
 }
        public void TestPublisherRepo_GetAll()
        {
            //Arrange
            PublisherRepository TestRepo = CreatePublisherTestRepo("PublisherGetAll");

            //Act
            var result = TestRepo.GetAll();

            //Assert
            Assert.IsTrue(result.Count() == _PublisherNumber);
        }
示例#29
0
 public AddBookForm()
 {
     _bookRepository      = new BookRepository();
     _authorRepository    = new AuthorRepository();
     _publisherRepository = new PublisherRepository();
     _bookCopyRepository  = new BookCopyRepository();
     InitializeComponent();
     LoadGenreComboBox();
     LoadAuthorComboBox();
     LoadPublisherComboBox();
 }
        public async Task TestPublisherRepo_GetGamesByPublisher()
        {
            //Arrange
            PublisherRepository TestRepo = CreatePublisherTestRepo("GamesByPublisher", true);

            //Act
            var result = await TestRepo.GetGamesByPublisher(_PublisherNumber - 1);

            //Assert
            Assert.IsTrue(result.Count() == 1);
        }
示例#31
0
 public string Put(int id, [FromBody] string name)
 {
     using (var ctx = new libraryContext())
     {
         var result = new PublisherRepository(ctx).Update(id, name);
         if (result == string.Empty)
         {
             ctx.SaveChanges();
         }
         return(result);
     }
 }
示例#32
0
        static void Main(string[] args)
        {
            //PublisherRepository.NumberOfRows();
            //PublisherRepository.TopTenPublishers();

            //PublisherRepository.BooksPerPub();
            //PublisherRepository.TotalPrice();

            PublisherRepository.Serialize();

            Console.ReadKey();
        }
示例#33
0
 public GameManager()
 {
     var unitOfWork = new UnitOfWork();
     _games = new GameRepository(unitOfWork);
     _publishers = new PublisherRepository(unitOfWork);
 }