public async Task PostCreateSection_CallItemSectionService() { var createItemTemplateSectionRequest = new CreateItemTemplateSectionRequest(); var itemTemplateSection = new ItemTemplateSection(); var itemTemplateSectionResponse = new ItemTemplateSectionResponse(); _itemTemplateSectionService.CreateItemTemplateSectionAsync(_executionContext, createItemTemplateSectionRequest) .Returns(itemTemplateSection); _mapper.Map <ItemTemplateSectionResponse>(itemTemplateSection) .Returns(itemTemplateSectionResponse); var result = await _itemTemplateSectionsController.PostCreateSectionAsync(_executionContext, createItemTemplateSectionRequest); result.StatusCode.Should().Be(201); result.Value.Should().Be(itemTemplateSectionResponse); }
public ItemTemplateSubCategory CreateItemTemplateSubCategory(ItemTemplateSection section, string suffix = null) { if (suffix == null) { suffix = RngUtil.GetRandomHexString(8); } return(new ItemTemplateSubCategory { Section = section, Note = $"some-note-{suffix}", Description = $"some-description-{suffix}", TechName = $"some-tech-name-{suffix}", Name = $"some-name-{suffix}" }); }
public async Task <ItemTemplateSection> CreateItemTemplateSectionAsync(NaheulbookExecutionContext executionContext, CreateItemTemplateSectionRequest request) { await _authorizationUtil.EnsureAdminAccessAsync(executionContext); var itemTemplateSection = new ItemTemplateSection { Name = request.Name, Special = string.Join(",", request.Specials), Note = request.Note, Icon = request.Icon, SubCategories = new List <ItemTemplateSubCategory>() }; using (var uow = _unitOfWorkFactory.CreateUnitOfWork()) { uow.ItemTemplateSections.Add(itemTemplateSection); await uow.SaveChangesAsync(); } return(itemTemplateSection); }