public IActionResult Get(int id) { var coffee = _coffeeRepository.GetById(id); if (coffee == null) { return(NotFound()); } return(Ok(coffee)); }
private static void SelectCoffee() { Console.Write("Please, insert coffee id: "); string a; int id; do { a = Console.ReadLine(); if (a == "") { sum = 0; StartFromInsertingCoins(); } int.TryParse(a, out id); if (id == 0 || coffeeRepo.GetById(id) == null) { Console.Write("Please, insert correct id: "); } else if (sum < coffeeRepo.GetById(id).Price) { Console.Write("You didn't insert enough money for this coffee, please choose another coffee or type enter to restart: "); } } while (id == 0 || coffeeRepo.GetById(id) == null || sum < coffeeRepo.GetById(id).Price); coffee = coffeeRepo.GetById(id); if (CheckIngredients("Sugar") && CheckIngredients("Coffee") && CheckIngredients("Water")) { order.Coffee = coffee; order.CoffeeId = coffee.Id; ingredientRepo.GetByName("Sugar").Quantity -= coffee.SugarPortion; ingredientRepo.Update(ingredientRepo.GetByName("Sugar")); ingredientRepo.GetByName("Water").Quantity -= coffee.WaterPortion; ingredientRepo.Update(ingredientRepo.GetByName("Water")); ingredientRepo.GetByName("Coffee").Quantity -= coffee.CoffeePortion; ingredientRepo.Update(ingredientRepo.GetByName("Coffee")); } }
public Coffee GetById(int id) { var coffee = repository.GetById(id); if (coffee == null) { throw new NotFoundException(nameof(Coffee), id); } return(coffee); }
public CoffeeBll GetById(Guid id) { return(coffeeRepository.GetById(id).Map()); }
public IActionResult GetById(int id) { return(Ok(_coffeeRepository.GetById(id))); }