public DrinkService(DrinkRepository drinkRepo, DrinkReviewRepository reviewRepo, BarRepository barRepo, ProfileRepository profileRepo) { _drinkRepo = drinkRepo; _reviewRepo = reviewRepo; _barRepo = barRepo; _profileRepo = profileRepo; }
public IHttpActionResult Purchase(decimal amount, int itemNumber) { if (DrinkRepository.RequestPurchase(amount, itemNumber) == true) { if (DrinkRepository._drinks.FirstOrDefault(d => d.Id == itemNumber).Quantity > 0) { return(Ok(DrinkRepository.MakePurchase(amount, itemNumber))); } } if (DrinkRepository._drinks.FirstOrDefault(d => d.Id == itemNumber).Quantity == 0) { return(new System.Web.Http.Results.ResponseMessageResult( Request.CreateErrorResponse( (HttpStatusCode)422, new HttpError("SOLD OUT!!!") ) )); } decimal remaining = DrinkRepository._drinks.FirstOrDefault(d => d.Id == itemNumber).Price - amount; return(new System.Web.Http.Results.ResponseMessageResult( Request.CreateErrorResponse( (HttpStatusCode)422, new HttpError("Please Deposit " + remaining) ) )); }
public async Task AddDrinkAsyncTestAsync() { var options = new DbContextOptionsBuilder <CoffeeDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; using (var context = new CoffeeDbContext(options)) { var newDrink = new Drink { DrinkName = "test", Description = "test", Price = 100, CategoryId = 1 }; var service = new DrinkRepository(context); await service.AddDrinkAsync(newDrink); } using (var context = new CoffeeDbContext(options)) { var newDrink = new Drink { DrinkName = "test", Description = "test", Price = 100, CategoryId = 1 }; var result = context.Drinks.Single(); //Assert.IsNull(result); Assert.AreEqual(1, context.Drinks.Count()); Assert.AreEqual(newDrink.DrinkName, result.DrinkName); } }
public async Task GetDrinksTestAsync() { var options = new DbContextOptionsBuilder <CoffeeDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; using (var context = new CoffeeDbContext(options)) { var newDrink1 = new Drink { DrinkName = "test", Description = "test", Price = 100, CategoryId = 1, Category = new Category() }; var newDrink2 = new Drink { DrinkName = "test2", Description = "test2", Price = 200, CategoryId = 2, Category = new Category() }; var service = new DrinkRepository(context); await service.AddDrinkAsync(newDrink1); await service.AddDrinkAsync(newDrink2); } using (var context = new CoffeeDbContext(options)) { var service = new DrinkRepository(context); var result = service.GetDrinks(); Assert.AreEqual(2, result.Count()); } }
public UnitOfWork(FurysApiDbContext context) { _context = context; //Add new Repositories in here BasketContents = new BasketContentsRepository(_context); DrinkComponents = new DrinkComponentRepository(_context); DrinkRecipes = new DrinkRecipeRepository(_context); Drinks = new DrinkRepository(_context); Orders = new OrderRepository(_context); }
public void Setup() { _connection = new SqliteConnection("Datasource=:memory:"); _connection.Open(); _options = new DbContextOptionsBuilder <BarOMeterContext>().UseSqlite(_connection).Options; _context = new BarOMeterContext(_options); _uut = new DrinkRepository(_context); _context.Database.EnsureCreated(); }
public async Task GetDrinksShouldReturnDefaultDrinksIfNoDrinksAvailable() { string userId = "userId"; var storageAccessServiceMock = new Mock <IStorageAccessService>(); storageAccessServiceMock .Setup(s => s.QueryTableAsync <DrinkTableEntity>("drinks", It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <TableContinuationToken>())) .ReturnsAsync(new PagedQueryResult <DrinkTableEntity>(new List <DrinkTableEntity>(), (string)null)); var drinkRepository = new DrinkRepository(storageAccessServiceMock.Object, new Mock <ILogger <DrinkRepository> >().Object); var result = await drinkRepository.GetDrinksAsync(userId); Assert.Equal(4, result.Count()); }
public static void Main() { Logger.RecordMessageToLog("werfewf"); IIngsRepository ingsRepo = new IngsRepository(); IDrinkRepository drinksRepo = new DrinkRepository(); IDisplay display = new ConsoleDisplay(); OrderController ordController = new ConsoleOrderController(drinksRepo, ingsRepo, display); Automat automat = new Automat(ordController, drinksRepo, display, ingsRepo, "geo:32434:43245"); AutomatEventService eventService = new AutomatEventService(automat, display); automat.StartAutomat(); }
private void InitializeRepositories() { ClientRepository = new ClientRepository(this.context); ClientConditionRepository = new ClientConditionRepository(this.context); ClientDrinkRepository = new ClientDrinkRepository(this.context); ClientFoodRepository = new ClientFoodRepository(this.context); ClientIncidentRepository = new ClientIncidentRepository(this.context); ClientInformationRepository = new ClientInformationRepository(this.context); DrinkRepository = new DrinkRepository(this.context); FoodRepository = new FoodRepository(this.context); IncidentRepository = new IncidentRepository(this.context); IncidentPhotoRepository = new IncidentPhotoRepository(this.context); UserRepository = new UserRepository(this.context); UserIncidentRepository = new UserIncidentRepository(this.context); UserTypeRepository = new UserTypeRepository(this.context); MessageRepository = new MessageRepository(this.context); }
/// <summary> /// Initialize the database and repositories. Inject the database context to repositories. /// </summary> public BaseController() { var db = new BarContext(); BarRepository = new BarRepository(db); BottleRepository = new BottleRepository(db); DrinkRepository = new DrinkRepository(db); DrinkBarRepository = new DrinkBarRepository(db); EventRepository = new EventRepository(db); IngredientDrinkRepository = new IngredientDrinkRepository(db); IngredientRepository = new IngredientRepository(db); OrderDrinkRepository = new OrderDrinkRepository(db); OrderRepository = new OrderRepository(db); QuantityRepository = new QuantityRepository(db); UnitRepository = new UnitRepository(db); UserBarRepository = new UserBarRepository(db); UserRepository = new UserRepository(db); UserRoleRepository = new UserRoleRepository(db); }
public TestWithSqlite() { _connection = new SqliteConnection(InMemoryConnectionString); _connection.Open(); var options = new DbContextOptionsBuilder <DrinkAppContext>() .UseSqlite(_connection) .Options; Context = new DrinkAppContext(options); Context.Database.EnsureCreated(); var data = new DrinkLoader().InitializeDrinksFromFile(); // Add drinks to the database Context.AddRange(data); Context.SaveChanges(); Repository = new DrinkRepository(Context); }
private async Task _Loading() { try { ViewModel.IsDrinksLoading = true; var barId = new BarId(new Guid("A8A4E6C2-2B7D-41EE-8B3D-2053D74FAD67")); IEnumerable <Drink> drinks = await DrinkRepository.GetAll(barId).ConfigureAwait(true); var uiDrinks = new List <UiDrink>(); foreach (var drink in drinks.OrderBy(x => x.Name)) { var imageUri = await ImageRepository.GetById(drink.ImageId).ConfigureAwait(true); var image = new BitmapImage(); image.CreateOptions = BitmapCreateOptions.IgnoreImageCache; image.UriSource = imageUri; var item = new UiDrink { Drink = drink, Image = image, IsImageLoading = true }; uiDrinks.Add(item); image.ImageFailed += (_sender, _e) => { image.UriSource = new Uri("ms-appx:///Assets/{00000000-0000-0000-0000-000000000000}.jpg"); item.IsImageLoading = false; }; image.ImageOpened += (_sender, _e) => { item.IsImageLoading = false; }; } ViewModel.DrinksView.Source = uiDrinks.ToList(); } finally { ViewModel.IsDrinksLoading = false; } }
static void Main(string[] args) { List <Ingredient> ingredients = new List <Ingredient>(); ingredients.Add(new Ingredient() { Name = "Vodka" }); ingredients.Add(new Ingredient() { Name = "Redbull" }); using (var ctx = new RepositoryContext()) { DrinkRepository DR = new DrinkRepository(ctx); List <Drink> loopDrinks = DR.FindDrinksByIngredient("Vodka"); foreach (var item in loopDrinks) { Console.WriteLine(item.Name); } } Console.WriteLine("done"); Console.ReadKey(); }
// Do Entity Framework code first public ActionResult DoCodeFirst() { DrinkRepository repository = new DrinkRepository(); CoffeeStore st1 = new CoffeeStore() { Eircode = "C15C98E", City = City.Limerick, Location = "O' Connell St. Limerick", OpeningTime = OpeningHour.AM0700, ClosingTime = ClosingHour.PM1730, StoreName = "Starbucks", Reviews = new List <Review>(), Drinks = new List <Drink>() }; CoffeeStore co1 = new CoffeeStore() { Eircode = "C15CK3E", City = City.Limerick, Location = "William st.. Limerick", OpeningTime = OpeningHour.AM0700, ClosingTime = ClosingHour.PM1730, StoreName = "Costa", Reviews = new List <Review>(), Drinks = new List <Drink>() }; CoffeeStore in1 = new CoffeeStore() { Eircode = "C15C01E", City = City.Limerick, Location = "Cecil St. Limerick", OpeningTime = OpeningHour.AM0700, ClosingTime = ClosingHour.PM1730, StoreName = "Insomnia", Reviews = new List <Review>(), Drinks = new List <Drink>() }; repository.AddStore(st1); repository.AddStore(co1); repository.AddStore(in1); Drink latte = new Drink() { DrinkName = "Cafe Latte", Price = 3.40, Eircode = co1.Eircode }; Review r1 = new Review() { CustomerName = "mg1", CustomerEmail = "*****@*****.**", ReviewDate = new DateTime(05 / 05 / 2012), Comment = "The coffee is way too expensive", Rating = 4, Eircode = co1.Eircode }; Review r2 = new Review() { CustomerName = "mg5", CustomerEmail = "*****@*****.**", ReviewDate = new DateTime(05 / 05 / 2012), Comment = "The service was shocking", Rating = 4, Eircode = st1.Eircode }; Review r3 = new Review() { CustomerName = "mj3", CustomerEmail = "*****@*****.**", ReviewDate = new DateTime(05 / 05 / 2012), Comment = "The coffee was best in Dublin", Rating = 4, Eircode = st1.Eircode }; Review r4 = new Review() { CustomerName = "keith", CustomerEmail = "*****@*****.**", ReviewDate = new DateTime(05 / 05 / 2012), Comment = "They had a wide variety of coffees", Rating = 4, Eircode = st1.Eircode }; repository.AddDrink(latte); repository.AddReview(r1); repository.AddReview(r2); repository.AddReview(r3); repository.AddReview(r4); Drink Mocha = new Drink() { DrinkName = "Mocha", Price = 3.70, Eircode = st1.Eircode }; Drink Frappacino = new Drink() { DrinkName = "Frappacino", Price = 4.40, Eircode = st1.Eircode }; Drink IceCafelatte = new Drink() { DrinkName = "Ice Cafe Latte", Price = 3.40, Eircode = st1.Eircode }; repository.AddDrink(Mocha); repository.AddDrink(Frappacino); repository.AddDrink(IceCafelatte); ViewBag.Words = new List <string> { "codeFirst", "completed" }; return(View()); }
public IHttpActionResult GetAll() { return(Ok(DrinkRepository.GetAll())); }
public DrinkBLL() { _drinkRepository = new DrinkRepository(); }
public DrinksController(DrinkRepository drinkRepo) { _drinkRepo = drinkRepo; }
public DrinkService(DrinkRepository repo) { _repo = repo; }