public ICommandResult Handle(UpdateNodeCommand command) { //Fail Fast Validation command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, Messages.Ex_ExceptionGeneric, command.Notifications)); } var node = _repository.GetById(command.Id); node.UpdateNode(command.Title); _repository.Update(node); return(new GenericCommandResult(true, Messages.Act_Update, node)); }
public async Task <IActionResult> Edit([FromBody] UpdateNodeCommand node) { if (ModelState.IsValid) { var nodeToUpdate = await _context.Node.FindAsync(node.Id); if (nodeToUpdate != null) { nodeToUpdate.Name = node.Name; nodeToUpdate.ParentId = node.ParentId; await _context.SaveChangesAsync(); return(NoContent()); } } return(BadRequest()); }
public GenericCommandResult Update([FromBody] UpdateNodeCommand command, [FromServices] NodeHandler handler) { return((GenericCommandResult)handler.Handle(command)); }