Пример #1
0
        public async Task <PrintingEditionsModelItem> GetById(long id)
        {
            var response = new PrintingEditionsModelItem();

            if (id == 0)
            {
                response.Errors.Add(ErrorConstants.ModelIsNull);
                return(response);
            }
            var product = await _printingEditionRepository.GetByProductIdAsync(id);

            if (product == null)
            {
                response.Errors.Add(ErrorConstants.ImpossibleToFindProduct);
                return(response);
            }
            var productModel = PrintingEditionMapper.MapEntityToModel(product.PrintingEdition);

            foreach (var item in product.Authors)
            {
                var author = AuthorMapper.MapEntityToModel(item);
                productModel.Authors.Add(author);
            }
            return(productModel);
        }