public async Task <IActionResult> Post([FromBody] Models.Core.Languages 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("languages", "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() })); } finally { } }
public async Task <IActionResult> Put([FromBody] Models.Core.Languages 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.Languages>(data.id); if (_data != null) { _data.code = data.code; _data.title = data.title; _data.icon = data.icon; _data.attach = data.attach; _data.descs = data.descs; _data.orders = data.orders; _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() })); } finally { } }