public ActionResult TENormalInsert([FromBody] CRUDModel <NetCorePSAV.Models.PSAVCrud.TipoEventoModel> value) { NetCorePSAV.Models.PSAVCrud.TipoEventoModel val = value.Value; val.ID = QueryCrud.UpdateTE(0, value.Value); TEList.Insert(TEList.Count, val); return(Json(TEList)); }
public ActionResult TENormalDelete([FromBody] CRUDModel <NetCorePSAV.Models.PSAVCrud.TipoEventoModel> value) { NetCorePSAV.Models.PSAVCrud.TipoEventoModel val = new NetCorePSAV.Models.PSAVCrud.TipoEventoModel(); val.ID = value.Key.ToString(); QueryCrud.UpdateTE(2, val); TEList.Remove(TEList.Where(or => or.ID == value.Key.ToString()).FirstOrDefault()); return(Json(value)); }
public ActionResult TENormalUpdate([FromBody] CRUDModel <NetCorePSAV.Models.PSAVCrud.TipoEventoModel> myObject) { var ord = myObject.Value; NetCorePSAV.Models.PSAVCrud.TipoEventoModel val = TEList.Where(or => or.ID == ord.ID).FirstOrDefault(); val.ID = ord.ID; val.Nombre = ord.Nombre; QueryCrud.UpdateTE(1, val); return(Json(myObject.Value)); }
public List <NetCorePSAV.Models.PSAVCrud.TipoEventoModel> GetTipoEventos() { string TabSQLSens = "SELECT * FROM psav_dev.tc_tipoevento"; List <NetCorePSAV.Models.PSAVCrud.TipoEventoModel> locations = new List <NetCorePSAV.Models.PSAVCrud.TipoEventoModel>(); MySqlConnection conn = new MySqlConnection(con); //estamos estableciendo conexión con mySql MySqlCommand cmd = new MySqlCommand(TabSQLSens, conn); //estamos ejecutando el código SELECT FROM conn.Open(); MySqlDataReader sdr = cmd.ExecuteReader();//le estamos diciendo que lea los datos guardados en la base de datos while (sdr.Read()) { NetCorePSAV.Models.PSAVCrud.TipoEventoModel location = new NetCorePSAV.Models.PSAVCrud.TipoEventoModel(); location.ID = sdr.GetValue(0).ToString(); location.Nombre = sdr.GetValue(1).ToString(); locations.Add(location); } conn.Close(); return(locations); }
public string UpdateTE(int typeUpdate, NetCorePSAV.Models.PSAVCrud.TipoEventoModel locationModel) { string queryToInsert = ""; string valor = ""; switch (typeUpdate) { case 0: queryToInsert = "insert into psav_dev.tc_tipoevento (tcte_nombe) values('" + locationModel.Nombre + "')"; valor = SaveWithIDReturn(queryToInsert); break; case 1: queryToInsert = "update psav_dev.tc_tipoevento set tcte_nombe='" + locationModel.Nombre + "' where tcte_id=" + locationModel.ID; SaveWithoutValidation(queryToInsert); break; case 2: queryToInsert = "delete from psav_dev.tc_tipoevento where tcte_id=" + locationModel.ID; SaveWithoutValidation(queryToInsert); break; } return(valor); }