public ActionResult <Drink> Put(int id, [FromBody] Drink drink) { Drink result = _drinkRepo.EditDrink(id, drink); if (result != null) { return(result); } return(NotFound()); }
internal object EditDrink(Drink updatedDrink) { Drink original = GetDrinkById(updatedDrink.Id); original.Name = updatedDrink.Name != null ? updatedDrink.Name : original.Name; original.Description = updatedDrink.Description != null ? updatedDrink.Description : original.Description; original.Price = updatedDrink.Price > 0 ? updatedDrink.Price : original.Price; return(_repo.EditDrink(original)); }