Пример #1
0
        public IActionResult CreateAuthorCollection([FromBody] IEnumerable <AuthorInputDto> authorsCollection)
        {
            if (authorsCollection == null)
            {
                return(BadRequest());
            }

            var result = _authorService.AddAuthorCollection(authorsCollection);

            if (!result.sucess)
            {
                throw new Exception("Creating authors collection failed on save");
            }

            var authorsToReturn = _mapper.Map <IEnumerable <AuthorInputDto>, IEnumerable <AuthorOutputDto> >(authorsCollection);
            var ids             = string.Join(",", result.ids);

            return(CreatedAtRoute("GetAuthorCollection",
                                  new { ids = ids },
                                  authorsToReturn));
        }