Esempio n. 1
0
        public async Task <ActionResult> EditAsync(GlossaryItemViewModel viewModel)
        {
            var item = await _glossaryRepository.GetAsync(viewModel.Id);

            if (item == null)
            {
                return(HttpNotFound());
            }

            if (viewModel.IsDeleting)
            {
                await _glossaryRepository.DeleteAsync(viewModel.Id);

                return(RedirectToAction(nameof(Index)));
            }

            if (ModelState.IsValid)
            {
                item.Title   = viewModel.Title;
                item.Content = viewModel.Content;
                await _glossaryRepository.UpdateAsync(item);

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(View("CreateEdit", viewModel));
            }
        }
Esempio n. 2
0
        public async Task DeleteGlossaryItems()
        {
            var subject = new GlossaryRepository();
            var result  = await subject.GetAllAsync(100);

            foreach (var item in result.Items)
            {
                await subject.DeleteAsync(item.RowKey);
            }
        }