Ejemplo n.º 1
0
 public SearchController(
     ISearchService searchService,
     ISolrService solrService,
     ILogger <SearchController> logger
     )
 {
     _searchService = searchService;
     _solrService   = solrService;
     _logger        = logger;
 }
Ejemplo n.º 2
0
        public static void ReadSampleData(BookContext context, ISolrService solrService)
        {
            Assembly assembly     = Assembly.GetExecutingAssembly();
            string   resourceName = "BookListing.DataAccess.SampleData.books.csv";

            using (var stream = assembly.GetManifestResourceStream(resourceName))
            {
                if (!context.Books.Any())
                {
                    var authorList    = new List <Author>();
                    var solrIndexList = new List <Book>();
                    var counter       = 0;
                    foreach (var line in CsvReader.ReadFromStream(stream))
                    {
                        var book = new Book();
                        book.BookNum       = Int32.TryParse(line[0], out int bookNum) ? bookNum : 0;
                        book.Title         = line[1];
                        book.AverageRating = decimal.TryParse(line[3], out decimal rating) ? rating : 0;
                        book.ISBN          = line[4];
                        book.ISBN13        = line[5];
                        book.LanguageCode  = line[6];
                        book.Pages         = Int32.TryParse(line[7], out int pages) ? pages : 0;
                        book.RatingsCount  = Int32.TryParse(line[8], out int ratingCount) ? ratingCount : 0;
                        book.ReviewCount   = Int32.TryParse(line[9], out int reviews) ? reviews : 0;


                        var authorName = line[2];
                        var author     = context.Authors.SingleOrDefault(m => m.Name.ToLower() == authorName.ToLower());
                        if (author == null)
                        {
                            author = authorList.SingleOrDefault(m => m.Name.ToLower() == authorName.ToLower());
                            if (author == null)
                            {
                                author = new Author {
                                    Name = authorName
                                };
                                authorList.Add(author);
                                context.Authors.Add(author);
                            }
                        }

                        book.Author = author;
                        solrIndexList.Add(book);
                        context.Books.Add(book);
                        counter++;
                        if (counter % 300 == 0)
                        {
                            context.SaveChanges();
                            solrService.IndexBooks(solrIndexList);
                            solrIndexList.Clear();
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public TodosController(
     ITodoItemService todoItemService,
     IRabbitMQService rabbitMQService,
     ISolrService solrService,
     IOptions <TodoSettings> config,
     IHostingEnvironment env,
     IHttpClientFactory clientFactory)
 {
     _todoItemService = todoItemService;
     _rabbitMQService = rabbitMQService;
     _solrService     = solrService;
     _config          = config;
     _env             = env;
     _clientFactory   = clientFactory;
 }
Ejemplo n.º 4
0
 public BookController(BookContext context, ISolrService solrService)
 {
     SolrService = solrService;
     Context     = context;
 }
Ejemplo n.º 5
0
 public IcecatFacade(Iicecat icecat, IDataAccessLayer dal, ISolrService <SolrResponse> solrService)
 {
     this._icecat      = icecat;
     this._dal         = dal;
     this._solrService = solrService;
 }
Ejemplo n.º 6
0
 public ShopController(ISolrService <SolrResponse> searchService)
 {
     _searchService = searchService;
 }
Ejemplo n.º 7
0
 public static void AddSampleData(BookContext context, ISolrService solrService, IUserService userService)
 {
     ReadSampleData(context, solrService);
     AddSampleUsers(context, userService);
 }
Ejemplo n.º 8
0
 public HangfireService(IFacade ifc, ISolrService <SolrResponse> solr, IOrderService <Order, CheckOutForm> orderService)
 {
     _ifc          = ifc;
     _solr         = solr;
     _orderService = orderService;
 }