public async Task <IActionResult> Post([FromBody] Models.Core.Permissions data) { try { using (var db = new TM.Core.Connection.Oracle()) { var nd = db.Connection.getUserFromToken(TM.Core.HttpContext.Header("Authorization")); if (nd == null) { return(Json(new { msg = TM.Core.Common.Message.error_token.ToString() })); } if (db.Connection.isExist("Permissions", "code", data.code)) { return(Json(new { msg = TM.Core.Common.Message.exist.ToString() })); } // data.id = Guid.NewGuid().ToString("N"); data.created_by = nd.ma_nd; data.created_at = DateTime.Now; await db.Connection.InsertOraAsync(data); return(Json(new { data = data, msg = TM.Core.Common.Message.success.ToString() })); } } catch (System.Exception) { return(Json(new { msg = TM.Core.Common.Message.danger.ToString() })); } }
public async Task <IActionResult> Put([FromBody] Models.Core.Permissions data) { try { using (var db = new TM.Core.Connection.Oracle()) { var nd = db.Connection.getUserFromToken(TM.Core.HttpContext.Header("Authorization")); if (nd == null) { return(Json(new { msg = TM.Core.Common.Message.error_token.ToString() })); } var _data = await db.Connection.GetAsync <Models.Core.Permissions>(data.id); if (_data != null) { //_data.code = data.code; _data.title = data.title; _data.orders = data.orders; _data.descs = data.descs; _data.updated_by = nd.ma_nd; _data.updated_at = DateTime.Now; _data.flag = data.flag; } await db.Connection.UpdateAsync(_data); return(Json(new { data = _data, msg = TM.Core.Common.Message.success.ToString() })); } } catch (System.Exception) { return(Json(new { msg = TM.Core.Common.Message.danger.ToString() })); } }