Пример #1
0
        public void Create_DisplayNameIsNullOrEmpty_ThrowsException()
        {
            //arrange
            var sectionTemplate = new SectionTemplate {
                Id = 1
            };
            var displayName = string.Empty;

            //act + assert
            Assert.That(() => _sectionNodeService.CreateSectionNode(sectionTemplate.Id, displayName, "Foobar"),
                        Throws.Exception.TypeOf <ArgumentException>()
                        .With.Message.EqualTo(string.Format(Ensure.ArgumentIsNullOrEmptyMessageFormat, "displayName")));
        }
Пример #2
0
        public JsonResult CreateSection(CreateSectionViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(JsonError(JsonRequestBehavior.DenyGet));
            }

            var newSectionNode =
                _mapper.Map <SectionNode, SectionNodeViewModel>(_sectionNodeService.CreateSectionNode(model.SectionTemplateId,
                                                                                                      model.DisplayName, model.UrlName));

            return(Json(newSectionNode, JsonRequestBehavior.DenyGet));
        }