public async Task<IActionResult> AddSection(AddSectionModel model)
        {
            var section = new Data.Models.Section()
            {
                Title = model.Title,
                Description = model.Description
            };

            await _sectionService.Create(section);
            return RedirectToAction("Index", "Section");
        }
Beispiel #2
0
        public async Task <IActionResult> Add(AddSectionModel sectionModel)
        {
            if (!ModelState.IsValid)
            {
                return(this.View(sectionModel));
            }

            bool found = await this.sections.AddNewSectionAsync(sectionModel.Name, sectionModel.IsForSmokers);

            if (!found)
            {
                TempData.AddErrorMessage(string.Format(ManagerConstants.SectionAlreadyExist, sectionModel.Name));
                return(this.View(sectionModel));
            }

            TempData.AddSuccessMessage(string.Format(ManagerConstants.SectionAddedSuccessfully, sectionModel.Name));
            return(this.RedirectToAction(nameof(All)));
        }
 public IActionResult Create()
 {
     var model = new AddSectionModel();
     return View(model);
 }