public async Task <IActionResult> CreateCatalog([FromBody, Bind("Title", "ParentCatalogId")] CatalogViewModel model) { if (!ModelState.IsValid) { return(BadRequest()); } var catalog = _mapper.Map <Catalog>(model); if (!string.IsNullOrWhiteSpace(model.ParentCatalogId)) { var parentCatalog = _catalogService.FindCatalogId(model.ParentCatalogId); catalog.ParentCatalog = parentCatalog; } await _catalogService.CreateCatalogAsync(catalog); return(Created("", _mapper.Map <CatalogViewModel>(catalog))); }