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"); }
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)); }
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()); }
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")); }