Example #1
0
        private async Task CreateDrink()
        {
            int numIngredients = 0;

            for (int i = 0; i < 6; i++)
            {
                if (Drink.Ingredients[i].Name != null)
                {
                    numIngredients++;
                }
            }
            //wichtige felder ausgefüllt
            if (Drink.Name != null &&
                Drink.Description != null &&
                numIngredients != 0)
            {
                var createTask = _drinkService.CreateDrink(Drink);

                ReturnCode statusCode = await createTask;

                await Task.WhenAll(createTask);

                if (statusCode == ReturnCode.success)
                {
                    await Task.Run(() => SimpleIoc.Default.GetInstance <IDialogService>().ShowMessage("Success", "Your drink will be added to the database."));

                    await _navigationService.NavigateAsync(Locator.MasterPage);
                }
                else
                {
                    await Task.Run(() => SimpleIoc.Default.GetInstance <IDialogService>().ShowMessage("Error", "Some unexpected error occured. Please try again later."));
                }
            }
            else
            {
                await Task.Run(() => SimpleIoc.Default.GetInstance <IDialogService>().ShowMessage("Error", "Some information is missing, please fill out name, description and at least one ingredient."));
            }
        }
Example #2
0
 public void Create(DrinkDto drinkDto)
 {
     drinkService.CreateDrink(drinkDto);
 }
 public void CreateDrink(int machineId, DrinkDto newDrink)
 {
     _drinkService.CreateDrink(machineId, newDrink);
 }