示例#1
0
        private async Task DeleteIngredient()
        {
            var repo = new MsSqlRepo.IngredientsRepository("Ingredients");
            int id   = Parameters.GetAndShift("id").Value;
            await repo.DeleteRowAsync(id);

            View.WriteLine(String.Format("Deleted row {0}", id));
        }
示例#2
0
        private async Task ListIngredient()
        {
            var repo = new MsSqlRepo.IngredientsRepository("Ingredients");
            List <Ingredients> ingredients = new List <Ingredients>();

            ingredients = (await repo.GetAllAsync()).ToList();
            ingredients[0].PrintKeys();
            ingredients.ForEach(a => a.Print());
        }
示例#3
0
        private async Task AddIngredient()
        {
            var         repo        = new MsSqlRepo.IngredientsRepository("Ingredients");
            Ingredients ingredients = new Ingredients();

            ingredients.Name  = Parameters.GetAndShift("name").Value;
            ingredients.Price = Parameters.GetAndShift("price").Value;
            int id = (await repo.InsertWithReturnAsync(ingredients));

            View.WriteLine(String.Format($"Added {1} Ingredient"));
        }
示例#4
0
        private async Task UpdateIngredient()
        {
            var repo = new MsSqlRepo.IngredientsRepository("Ingredients");
            var ingredientToUpdate = new Ingredients();

            ingredientToUpdate.ID = Parameters.GetAndShift("id").Value;
            foreach (var item in Parameters)
            {
                if (item.Key == "name")
                {
                    ingredientToUpdate.Name = item.Value;
                }
                if (item.Key == "price")
                {
                    ingredientToUpdate.Price = item.Value;
                }
            }
            await repo.UpdateAsync(ingredientToUpdate);

            View.WriteLine("1 ingredient was updated");
        }