public IHttpActionResult GET() { try { List <string> bcList = new List <string>(); bcList = FileDistributor.GetBlockChains(); return(Ok(bcList)); } catch (Exception e) { return(BadRequest()); } }
public IHttpActionResult Get(string qr) { if (!keyHandler.CheckApiKey(this.Request)) { return(new ForbiddenActionResult(Request, "access denied")); } try { var result = mapper.GetProductByQr(qr); if (result != null) { result.Process = mapper.GetProcess(result.ProcessId); result.CurrentTreatment = mapper.GetTreatment(result.CurrrentTreatmentId); #region bc test if (result.CurrentTreatment != null && result.CurrentTreatment.OutgoingState.Final) { BlockChain bc = new BlockChain(2); foreach (var step in result.Process.Steps) { string stateAsString = JsonConvert.SerializeObject(step); Block bs = bc.NewBlock(stateAsString); bc.AddBlock(bs); } FileDistributor fd = new FileDistributor(); fd.SaveBlockChain(bc, result.QRCode); } #endregion return(Ok(result)); } return(NotFound()); } catch (Exception e) { return(BadRequest()); } }
public IHttpActionResult GET(string qr) { string content = FileDistributor.GetBlockChainFileContent(qr); return(Ok(content)); }