public IHttpActionResult FindUsages([FromBody]int? id) { try { if (!ModelState.IsValid) { return BadRequest(ModelState); } var services = new DecoderServices(); var list = services.FindProcedureUsages(id); return Json(list.ToArray()); } catch (Exception e) { //return Json(new { error = e.ToString() }); return InternalServerError(e); } }
public IHttpActionResult DeleteDecoder([FromBody]int? id) { try { if (!ModelState.IsValid) { return BadRequest(ModelState); //return Json(new { error = "modèle non valide" }); } var services = new DecoderServices(); services.DeleteDecoder(id); return Ok(); } catch (Exception e) { //return Json(new { error = e.ToString() }); return InternalServerError(e); } }
public IHttpActionResult GetAllBlockInfos() { try { if (!ModelState.IsValid) { return BadRequest(ModelState); //return Json(new { error = "modèle non valide" }); } var services = new DecoderServices(); //var map = services.GetCategoryInfos(); //return Json(new JavaScriptSerializer().Serialize(map)); var list = services.GetAllBlockInfos(); return Json(list.ToArray()); } catch (Exception e) { //return Json(new { error = e.ToString() }); return InternalServerError(e); } }
public IHttpActionResult PostDecoder(Decoder decoder) { try { if (!ModelState.IsValid) { return BadRequest(ModelState); } var services = new DecoderServices(); if (decoder.Id == null) { var decoderId = services.AddDecoder(decoder); MyHub.NotifyRefresh(); return Json(new { id = decoderId }); } else { var mustRefreshToolbox = services.UpdateDecoder(decoder); if (mustRefreshToolbox) { MyHub.NotifyRefresh(); } return Json(new { id = decoder.Id }); } } catch (Exception e) { return InternalServerError(e); } }
public IHttpActionResult GetDecoderDef([FromBody]int? id) { try { if (!ModelState.IsValid) { return BadRequest(ModelState); } var services = new DecoderServices(); var decoder = services.GetDecoder(id); return Json(new { decoder.Name, decoder.Version, decoder.Category, decoder.Tags, decoder.BlocklyDef }); } catch (Exception e) { return InternalServerError(e); } }