Ejemplo n.º 1
0
        private async Task UpdateArticle()
        {
            var repo            = new MsSqlRepo.ArticlesRepository("Articles");
            var articleToUpdate = new Articles();

            articleToUpdate.ID = Parameters.GetAndShift("id").Value;
            foreach (var item in Parameters)
            {
                if (item.Key == "name")
                {
                    articleToUpdate.Name = item.Value;
                }
                if (item.Key == "price")
                {
                    articleToUpdate.BasePrice = item.Value;
                }
                if (item.Key == "type")
                {
                    articleToUpdate.Type = item.Value;
                }
            }
            var articleList = new List <Articles>()
            {
                articleToUpdate
            };
            await repo.UpdateAsync(articleToUpdate);

            View.WriteLine("1 article was updated");
        }
Ejemplo n.º 2
0
        private async Task DeleteArticle()
        {
            var repo = new MsSqlRepo.ArticlesRepository("Articles");
            int id   = Parameters.GetAndShift("id").Value;
            await repo.DeleteRowAsync(id);

            View.WriteLine(String.Format("Deleted row {0}", id));
        }
Ejemplo n.º 3
0
        private async Task ListArticle()
        {
            var             repo     = new MsSqlRepo.ArticlesRepository("Articles");
            List <Articles> articles = new List <Articles>();

            articles = (await repo.GetAllAsync()).ToList();
            articles[0].PrintKeys();
            articles.ForEach(article => article.Print());
        }
Ejemplo n.º 4
0
        private async Task AddArticle()
        {
            var repo       = new MsSqlRepo.ArticlesRepository("Articles");
            var newArticle = new Articles();

            newArticle.Name      = Parameters.GetAndShift("name").Value;
            newArticle.BasePrice = Parameters.GetAndShift("price").Value;
            newArticle.Type      = Parameters.GetAndShift("type").Value;
            int n = (await repo.InsertWithReturnAsync(newArticle));

            View.WriteLine(String.Format($"Added {n} Article"));
        }