public async Task <IActionResult> Post([FromBody] Models.Core.ContractCustomer 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("contract_customer", "ma_gd", data.khachhang.ma_gd)) return Json(new { msg = "exist" }); //data.khachhang.cc_id = Guid.NewGuid().ToString(); //data.khachhang.app_key = "cc_2"; data.id = Guid.NewGuid().ToString("N"); data.created_by = nd.ma_nd; data.created_at = DateTime.Now; data.flag = 1; await db.Connection.InsertOraAsync(data); // var qry = $"select * from CONTRACT_CUSTOMER_KH where hdkh_id='{data.hdkh_id}' and flag=1"; var rs = db.Connection.QueryFirstOrDefault <ContractCustomerKH>(qry); return(Json(new { data = rs, 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.ContractCustomer 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() })); } data.updated_by = nd.ma_nd; data.updated_at = DateTime.Now; 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 { } }