Ejemplo n.º 1
0
        public async Task <IActionResult> AddCatalog([FromBody] CatalogDto catalogDto, int userId)
        {
            // If didn't save return message
            if (!await _catalogService.AddCatalog(catalogDto, userId))
            {
                return(BadRequest("Nie udało się dodać katalogu"));
            }

            return(StatusCode(201));
        }
Ejemplo n.º 2
0
        public async Task <bool> AddCatalog(CatalogDto catalogDto, int userId)
        {
            if (catalogDto == null)
            {
                return(false);
            }

            // Only unique names for catalog
            if (_catalogRepository.IsExistCatalog(catalogDto.CatalogName, userId))
            {
                return(false);
            }

            // new catalog to add with properties from view
            var catalogEntity = new CatalogEntity
            {
                CatalogName = catalogDto.CatalogName,
                UserId      = userId
            };

            return(await _catalogRepository.CreateCatalogAsync(catalogEntity));
        }