Beispiel #1
0
        public async Task <IActionResult> UpdateNode([FromBody] UpdateNodeDTO nodeDTO)
        {
            try
            {
                await _treeViewService.UpdateNode(nodeDTO);

                return(NoContent());
            }
            catch (NotFoundException)
            {
                return(NotFound());
            }
            catch (System.Exception ex)
            {
                return(BadRequest(ErrorDTO.Create(ex.Message)));
            }
        }
Beispiel #2
0
        public async Task UpdateNode(UpdateNodeDTO updateNode)
        {
            Category category = _dbContext.Categories.Include(c => c.ParentCategory).FirstOrDefault(c => c.Id == updateNode.Id);
            Page     page     = _dbContext.Pages.Include(c => c.Category).FirstOrDefault(p => p.Id == updateNode.Id);

            if (category != null)
            {
                _dbContext.Categories.Update(updateNode.ToCategory(category));
            }
            else if (page != null)
            {
                _dbContext.Pages.Update(updateNode.ToPage(page));
            }
            else
            {
                throw new NotFoundException();
            }

            await _dbContext.SaveChangesAsync();
        }