public async Task <ActionResult> Put(string id, NodeViewModelCreate data) { if (!string.IsNullOrEmpty(data.Id) && data.Id.ToLower() != id.ToLower()) { var problemDetail = ProblemDetailsFactory.CreateProblemDetails(HttpContext, (int)HttpStatusCode.BadRequest); problemDetail.Title = "The public id does not match the one from message body"; return(BadRequest(problemDetail)); } if (!await nodes.UpdateNodeAsync(data.ToDomainObject())) { return(NotFound()); } return(NoContent()); }
public async Task <ActionResult <NodeViewModelGet> > Post(NodeViewModelCreate data) { var created = await nodes.CreateNodeAsync(data.ToDomainObject()); if (created == null) { var problemDetail = ProblemDetailsFactory.CreateProblemDetails(HttpContext, (int)HttpStatusCode.BadRequest); problemDetail.Status = (int)HttpStatusCode.Conflict; problemDetail.Title = $"Node '{data.Id}' already exists"; return(Conflict(problemDetail)); } // if this node is first being added on empty DB it will insert bestblockhash await blockParser.InitializeDB(); return(CreatedAtAction(nameof(Get), new { id = created.ToExternalId() }, new NodeViewModelGet(created))); }