Example #1
0
        public async Task <PrintingEditionModel> CreatePrintingEditionAsync(PrintingEditionModel model)
        {
            var existsPrintingEdition = await _printingEditionRepository.GetPrintingEditionByTitleAsync(model.Title);

            if (existsPrintingEdition is not null)
            {
                throw new ServerException(Constants.Errors.ALREADY_EXISTS);
            }

            var printingEdition = _autoMapper.Map <PrintingEdition>(model);
            await _printingEditionRepository.CreateAsync(printingEdition);

            await _authorInPrinting.AddAuthorToPEAsync(model.AuthorsId, printingEdition.Id);

            var printingEditionModel = _autoMapper.Map <PrintingEditionModel>(printingEdition);

            return(printingEditionModel);
        }