public HomeController(IMenuRepository <Style> styleMenuRepository, IMenuRepository <Available> beerAvailibilityMenuRepository, IMenuRepository <Glass> glassMenuRepository, BeerRepository beerRepository) { this.styleMenuRepository = styleMenuRepository; this.beerAvailibilityMenuRepository = beerAvailibilityMenuRepository; this.glassMenuRepository = glassMenuRepository; this.beerRepository = beerRepository; }
public static IBeerRepository GetRepository() { var ctl = ComponentFactory.GetComponent<IBeerRepository>(); if (ctl == null) { ctl = new BeerRepository(); ComponentFactory.RegisterComponentInstance<IBeerRepository>(ctl); } return ctl; }
public static Dictionary <Tag, int> GetTagsWithOccurences(List <Beer> beers) { BeerRepository br = new BeerRepository(); List <Tag> listOfTags = new List <Tag>(); listOfTags.AddRange(br.RetrieveTagsFromBeers(beers)); var groups = listOfTags.GroupBy(s => s) .Select(s => new { Tag = s.Key, Count = s.Count() }); return(groups.ToDictionary(g => g.Tag, g => g.Count)); }
public static HashSet <Beer> GetBeersContainingTags(List <Tag> tags) { BeerRepository br = new BeerRepository(); var beers = br.RetrieveAll(); HashSet <Beer> foundBeers = new HashSet <Beer>(); foreach (var tag in tags) { foundBeers.UnionWith(br.RetrieveBeersByTag(tag)); } return(foundBeers); }
static void Main(string[] args) { using (var context = new AppDbContext()) { //PrintBreweriesFromDb(context); //PrintBeersFromDb(context); var repo = new BeerRepository(); var tagRepo = new TagRepository(); PrintNamesOfPopularBeers(context); } Console.ReadLine(); }
public static List <Beer> GetBeersByIds(List <string> ids) { BeerRepository br = new BeerRepository(); List <Beer> list = new List <Beer>(); foreach (var id in ids) { var beerId = int.Parse(id); list.Add(br.RetrieveById(beerId)); } return(list); }
public void Test_Create() { using (var cluster = new Cluster()) { using (var bucket = cluster.OpenBucket("beer-sample")) { var repository = new BeerRepository(bucket); var beer = new Couchbase.Data.RepositoryExample.Models.Beer { Id = "bud_light", Name = "Bud Light", Type = "beer" }; repository.Save(beer); } } }
public async Task ApplyPercentPromo(int quantity, decimal cost, string percentMsg) { var beerRepo = new BeerRepository(_context, null); var order = new Order { OrderDetails = new List <Stock> { new Stock { BeerId = 1, Quantity = quantity } } }; var beers = await beerRepo.ReadAllFromListAsync(order.OrderDetails.Select(od => od.BeerId)); var sut = new Quote(order, beers); Assert.That(sut.Cost, Is.EqualTo(cost)); Assert.That(sut.Summary, Has.Exactly(1).Matches <string>(s => s.Contains(percentMsg))); }
static void Main(string[] args) { BeerRepository br = new BeerRepository(); TagRepository tr = new TagRepository(); RegionRepository rr = new RegionRepository(); var region = rr.RetrieveAll().Take(1).First(); var popularBeers = BeerService.GetPopularBeers().Take(3).ToList(); Console.WriteLine("Your picked beers were:"); popularBeers.ForEach(b => Console.WriteLine(b.Name)); Console.WriteLine(); Console.WriteLine("Our recommendation is:"); var finalyDone = RecommendationService.Recommend(popularBeers, 10 /*, region*/); var fD = RecommendationService.RecommendBeersCombined(popularBeers, 5); finalyDone.ForEach(x => Console.WriteLine(x.Name)); Console.ReadKey(); }
public ActionResult Create(string placeId, string beerId, string comment) { if (placeId == "" || beerId == "" || comment == "") { return(Content("FAIL")); } var place = PlaceRepository.Get(placeId); var beer = BeerRepository.Get(beerId); var tap = new Tap { Beer = beer, Place = place, Username = SessionUser.Current.Username, Timestamp = DateTime.Now, Comment = comment }; TapRepository.Create(tap); return(Content("OK")); }
public UnitOfWork(string?connectionString, bool isPostgres = false) { // Based on our database implementation, we'll need a reference to the last row inserted string rowInsertRetrievalQuery; // If no connection string is passed, we'll assume we're running with our SQLite database provider if (string.IsNullOrWhiteSpace(connectionString)) { _dbConnection = new SqliteConnection("Data Source=:memory:"); rowInsertRetrievalQuery = "; SELECT last_insert_rowid();"; } else { _dbConnection = isPostgres ? (IDbConnection) new NpgsqlConnection(connectionString) : new SqlConnection(connectionString); rowInsertRetrievalQuery = isPostgres ? "returning Id;" : "; SELECT CAST(SCOPE_IDENTITY() as int);"; } // Open our connection, begin our transaction, and instantiate our repositories _dbConnection.Open(); _dbTransaction = _dbConnection.BeginTransaction(); BreweryRepository = new BreweryRepository(_dbTransaction, rowInsertRetrievalQuery); BeerRepository = new BeerRepository(_dbTransaction, rowInsertRetrievalQuery); // Once our connection is open, if we're running SQLite for unit tests (or that actual application), let's seed some data if (string.IsNullOrWhiteSpace(connectionString)) { try { // We'll seed a couple breweries each with an address and several beers SeedDatabase(_dbConnection); } catch (Exception e) { Console.WriteLine($"Could not seed the database: {e.Message}"); } } }
public BeerController() { this.beerRepository = new BeerRepository(); }
public TapsController() { BeerRepository = new BeerRepository(); TapRepository = new TapRepository(); }
public AutoCompleteController() { BeerRepository = new BeerRepository(); BreweryRepository = new BreweryRepository(); }
public BeersController() { BeerRepository = new BeerRepository(); }
public BeerService(BeerContext beerContext, ILogger <BeerService> logger, BeerRepository beerRepository) { _logger = logger; _beerContext = beerContext; _beerRepository = beerRepository; }
public EditController(BeerRepository repo) { _repo = repo; }
public TapController() { BeerRepository = new BeerRepository(); PlaceRepository = new PlaceRepository(); TapRepository = new TapRepository(); }
public BeersController(BeerRepository beerRepository) { BeerRepository = beerRepository; }
private BeerService() { beerRepository = new BeerRepository(); }
public BeerController(BeerRepository repository) { Repository = repository; }
public BeerController(BeerRepository repository) { _repository = repository; }
public static List <Beer> GetAllBeers() { var repository = new BeerRepository(); return(repository.RetrieveAll()); }
public WholesalersController(ILogger <WholesalersController> logger, IMapper mapper, WholesalerRepository repository, BeerRepository beerRepository) : base(logger, mapper) { _repository = repository; _beerRepository = beerRepository; }
public MenuController(BeerRepository repo) { _repo = repo; }
public BeerServiceImpl(BeerRepository beerRepository, MessagingService messagingService) { _beerRepository = beerRepository; _messagingService = messagingService; }
public AutoCompleteController() { PlaceRepository = new PlaceRepository(); BeerRepository = new BeerRepository(); }
public BeersController(ILogger <BeersController> logger, IMapper mapper, BeerRepository repository, BreweryRepository breweryRepository) : base(logger, mapper) { _repository = repository; _breweryRepository = breweryRepository; }