// When[("یک دسته بندی با عنوان کتابهای تاریخی ایجاد میکنم")]
        private void When()
        {
            var bookCategoryDto = new AddBookCategoryDto()
            {
                Title = "کتابهای تاریخی"
            };

            sut.Add(bookCategoryDto);
        }
예제 #2
0
        public int Add(AddBookCategoryDto dto)
        {
            BookCategory bookCategory = new BookCategory()
            {
                Title = dto.Title
            };

            _bookCategoryRepository.Add(bookCategory);
            _unitOfWork.Complete();
            return(bookCategory.Id);
        }
예제 #3
0
        public async Task <int> AddCategory(AddBookCategoryDto dto)
        {
            BookCategory bookCategory = new BookCategory
            {
                Title = dto.Title
            };

            _repository.Add(bookCategory);
            await _unitOfWork.Complete();

            return(bookCategory.Id);
        }
예제 #4
0
        public void Add_add_book_category_properly()
        {
            //Arrange
            AddBookCategoryDto dto = new AddBookCategoryDto()
            {
                Title = "dummy-title",
            };

            //Act
            var actualReturnedId = sut.Add(dto);

            //Assert
            var expected = readContext.BookCategories.Single(_ => _.Id == actualReturnedId);

            expected.Title.Should().Be("dummy-title");
        }
        public async Task <IActionResult> CreateBookCategory([FromBody] AddBookCategoryDto model)
        {
            try
            {
                var bookCategory = _mapper.Map <BookCategory>(model);
                var result       = await _bookCategoryManager.CreateBookCategory(bookCategory);

                if (!result)
                {
                    return(Ok(new JsonMessageResult("Fail", 0, null)));
                }
                return(CreatedAtAction(nameof(BookCategories), bookCategory));
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);

                return(Ok(new JsonMessageResult(e.Message, 0, null)));
            }
        }
예제 #6
0
        public async void Add_add_category_properly()
        {
            var db          = new EFInMemoryDatabase();
            var context     = db.CreateDataContext <EFDataContext>();
            var readContext = db.CreateDataContext <EFDataContext>();
            var repository  = new EFBookCategoryRepository(context);
            var unitOfWork  = new EFUnitOfWork(context);
            var category    = new BookCategory {
                Title = "dummy-title"
            };
            var dto = new AddBookCategoryDto {
                Title = category.Title
            };
            var sut = new BookCategoryAppService(unitOfWork, repository);

            var actual = await sut.AddCategory(dto);

            var expected = readContext.BookCategories.Single(_ => _.Id == actual);

            expected.Title.Should().Be(dto.Title);
        }
        public async Task <int> Add(AddBookCategoryDto dto)
        {
            int addedId = await _service.AddCategory(dto);

            return(addedId);
        }
예제 #8
0
 public int Add([Required][FromBody] AddBookCategoryDto dto)
 {
     return(_service.Add(dto));
 }