Exemple #1
0
 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;
 }
Exemple #2
0
        public static IBeerRepository GetRepository()
        {
            var ctl = ComponentFactory.GetComponent<IBeerRepository>();

            if (ctl == null)
            {
                ctl = new BeerRepository();
                ComponentFactory.RegisterComponentInstance<IBeerRepository>(ctl);
            }
            return ctl;
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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();
        }
Exemple #6
0
        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 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);

                }
            }
        }
Exemple #9
0
        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)));
        }
Exemple #10
0
        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();
        }
Exemple #11
0
        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"));
        }
Exemple #12
0
        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();
 }
Exemple #14
0
		public TapsController()
		{
			BeerRepository = new BeerRepository();
			TapRepository = new TapRepository();
		}
        public AutoCompleteController()
        {
            BeerRepository = new BeerRepository();
			BreweryRepository = new BreweryRepository();
        }
 public BeersController()
 {
     BeerRepository = new BeerRepository();
 }
Exemple #17
0
 public BeerService(BeerContext beerContext, ILogger <BeerService> logger, BeerRepository beerRepository)
 {
     _logger         = logger;
     _beerContext    = beerContext;
     _beerRepository = beerRepository;
 }
Exemple #18
0
 public EditController(BeerRepository repo)
 {
     _repo = repo;
 }
Exemple #19
0
 public TapController()
 {
     BeerRepository  = new BeerRepository();
     PlaceRepository = new PlaceRepository();
     TapRepository   = new TapRepository();
 }
Exemple #20
0
 public BeersController(BeerRepository beerRepository)
 {
     BeerRepository = beerRepository;
 }
 private BeerService()
 {
     beerRepository = new BeerRepository();
 }
 public BeerController(BeerRepository repository)
 {
     Repository = repository;
 }
 public BeerController(BeerRepository repository)
 {
     _repository = repository;
 }
Exemple #24
0
        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 BeersController()
 {
     BeerRepository = new BeerRepository();
 }
Exemple #27
0
 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;
 }
 public AutoCompleteController()
 {
     PlaceRepository = new PlaceRepository();
     BeerRepository  = new BeerRepository();
 }