public async Task <UcSaveGraphResponse> Handle(UcSaveGraphRequest message) { var masterGraph = await this.repo.GetById(message.MasterGuid); var newGraphId = masterGraph.AddGraph(message); await this.repo.Update(masterGraph); var response = new UcSaveGraphResponse(newGraphId.ToString(), true); return(response); }
[HttpPost("SaveGraph")] // master graph guid as route param? public async Task <ActionResult> SaveGraph([FromBody] SaveGraphRequest request) { var masterGuid = Guid.NewGuid(); var ucRequest = new UcSaveGraphRequest(request.Content, request.Title, request.GraphType, masterGuid); var result = await this.saveGraphUseCase.Handle(ucRequest); var response = new JsonContentResult { StatusCode = (int?)(result.Success ? HttpStatusCode.OK : HttpStatusCode.BadRequest), Content = JsonSerializer.SerializeObject(result) }; return(response); }
public Guid AddGraph(UcSaveGraphRequest message) { var graph = new Graph { Data = message.GraphContent, Title = message.Title, MasterGraphId = message.MasterGuid, GraphTypeId = message.GraphType, // check this? Id = Guid.NewGuid() }; this.Graphs.Add(graph); return(graph.Id); }