public Section AddSection(CreateSectionBindingModel model)
        {
            var section = this.Mapper.Map <Section>(model);

            this.DbContext.Sections.Add(section);
            this.DbContext.SaveChanges();

            return(section);
        }
        public CreateSectionBindingModel PrepareSectionForCreation(int mainSectioId)
        {
            var mainSection = this.DbContext.MainSections.Find(mainSectioId);

            if (mainSection == null)
            {
                return(null);
            }

            var model = new CreateSectionBindingModel()
            {
                MainSectionId = mainSection.Id
            };

            return(model);
        }
Exemplo n.º 3
0
        public IActionResult Create(CreateSectionBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var section = this.adminSectionService.AddSection(model);

            if (section == null)
            {
                return(NotFound());
            }

            this.TempData.Put("__Message", new MessageModel()
            {
                Type    = MessageType.Success,
                Message = WebConstants.SectionCreation
            });

            return(RedirectToAction("/"));
        }