コード例 #1
0
        public IActionResult Index()
        {
            var viewModel = new RemoveSectionViewModel
            {
                AllSections = this.removeSectionService.GetAllSections(),
            };

            var model = new RemoveSectionBaseModel
            {
                RemoveSectionInputModel = new RemoveSectionInputModel(),
                RemoveSectionViewModel  = viewModel,
            };

            return(this.View(model));
        }
コード例 #2
0
        public async Task <IActionResult> RemoveSection(RemoveSectionBaseModel model)
        {
            if (this.ModelState.IsValid)
            {
                Tuple <string, int> removedSection =
                    await this.removeSectionService.RemoveSection(model.RemoveSectionInputModel.Id);

                this.TempData["Success"] = string.Format(
                    MessageConstants.SuccessfullyRemoveSection,
                    removedSection.Item1.ToUpper(),
                    removedSection.Item2);
                return(this.RedirectToAction("Index", "RemoveSection"));
            }
            else
            {
                this.TempData["Error"] = MessageConstants.InvalidInputModel;
                return(this.RedirectToAction("Index", "RemoveSection", model));
            }
        }