public async Task <IActionResult> Post([FromBody] ModeAppDTO body) { try { await Db.Connection.OpenAsync(); var query = new ModeAppQuery(Db); body.Db = Db; await body.UpdateInsertAsync(); var response = new ResponseModeApp(); response.message = "Data Berhasil Disimpan !"; response.status = 0; return(new OkObjectResult(response)); } catch (Exception exc) { var response = new ResponseModeApp(); response.message = "Error ! " + exc.ToString(); response.status = 1; return(new OkObjectResult(response)); } }
public async Task <IActionResult> GetModeApp() { try { await Db.Connection.OpenAsync(); var query = new ModeAppQuery(Db); var result = await query.FindOneAsync(); if (result != null) { var returnedJson = "{"; returnedJson += "\"" + "mode" + "\": " + result.Mode + ","; returnedJson += "}"; // parse the json response so that we can get at the key/value pairs dynamic api = JObject.Parse(returnedJson); return(new OkObjectResult(api)); } else { var response = new ResponseModeApp(); response.message = "Data tidak ditemukan !"; response.status = 1; return(new OkObjectResult(response)); } } catch (Exception exc) { var response = new ResponseModeApp(); response.message = "Error ! " + exc.ToString(); response.status = 1; return(new OkObjectResult(response)); } }