public async Task <IActionResult> PostCopy(string isbn, [FromBody] ItemCopyDto copyDto)
        {
            var copy    = copyDto.ToDbModel();
            var created = await _copyRepository.Create(copy.Number, copy.ISBN, copy.IsAvailable, copy.Type);

            return(Created($"/{copy.Number}", copyDto));
        }
Esempio n. 2
0
        public static ItemCopyDto ToDto(this DbItemCopy copy)
        {
            var dto = new ItemCopyDto()
            {
                Number      = copy.Number,
                ISBN        = copy.ISBN,
                IsAvailable = copy.IsAvailable,
                Type        = (EItemCopyTypeDto)(int)copy.Type
            };

            return(dto);
        }
Esempio n. 3
0
        public static DbItemCopy ToDbModel(this ItemCopyDto dto)
        {
            var copy = new DbItemCopy()
            {
                Number      = dto.Number,
                ISBN        = dto.ISBN,
                IsAvailable = dto.IsAvailable,
                Type        = (EDbItemCopyType)(int)dto.Type
            };

            return(copy);
        }
Esempio n. 4
0
        private async void And_the_item_copies_are_available()
        {
            _itemCopyDto = new ItemCopyDto()
            {
                ISBN        = _itemDto.ISBN,
                Number      = 1,
                Type        = EItemCopyTypeDto.Normal,
                IsAvailable = true
            };

            var itemCopyDtoJson = JsonConvert.SerializeObject(_itemCopyDto, new StringEnumConverter());
            var response        = await _client.PostAsync("/v1/items/9781613776056/copies", new StringContent(itemCopyDtoJson, Encoding.UTF8, "application/json"));
        }