public IActionResult Index() { var path = Path.Combine(this.environment.WebRootPath, "Website Elements"); var viewModel = new AddPartToSectionViewModel { AllSections = this.addPartToSectionService.GetAllSections(), AllElements = this.addPartToSectionService.GetAllElements(path), }; var model = new AddPartToSectionBaseModel { AddPartToSectionInputModel = new AddPartToSectionInputModel(), AddPartToSectionViewModel = viewModel, }; return(this.View(model)); }
public async Task <IActionResult> AddPartToSection(AddPartToSectionBaseModel model) { if (this.ModelState.IsValid) { string sectionName = await this.addPartToSectionService.AddPartToSection(model.AddPartToSectionInputModel); this.TempData["Success"] = string.Format( MessageConstants.SuccessfullyAddPartToSection, model.AddPartToSectionInputModel.Name.ToUpper(), sectionName.ToUpper()); return(this.RedirectToAction("Index", "AddPartToSection")); } else { this.TempData["Error"] = MessageConstants.InvalidInputModel; return(this.RedirectToAction("Index", "AddPartToSection", model)); } }