コード例 #1
0
        public async Task <IActionResult> EditCatalog(string catalogId, [FromBody, Bind("Title", "ParentCatalogId")] CatalogViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var catalog = _mapper.Map <Catalog>(model);

            await _catalogService.EditCatalogAsync(catalogId, catalog);

            return(Ok(_mapper.Map <CatalogViewModel>(catalog)));
        }
コード例 #2
0
        public async Task <ActionResult <CatalogsEntity> > EditCatalogAsync(int catalogId, CatalogsEntity catalog)
        {
            if (!_catalogService.CheckIfCatalogExit(catalog))
            {
                var model = await _catalogService.EditCatalogAsync(catalogId, catalog);

                //var result = _mapper.Map<CatalogsEntity>(catalogs);
                var location = _linkGanarator.GetPathByAction("GetCatalogByIdAsync", "Catalogs", new { id = model.CatalogId });
                return(model);
            }
            else
            {
                return(BadRequest("catalog has already been created"));
            }
        }