public ActionResult CTNormalInsert([FromBody] CRUDModel <NetCorePSAV.Models.PSAVCrud.ILCrudModel.Categoria> value) { NetCorePSAV.Models.PSAVCrud.ILCrudModel.Categoria val = value.Value; val.ID = QueryCrud.UpdateCategories(0, value.Value); CategoriasList.Insert(CategoriasList.Count, val); return(Json(EtiquetasList)); }
public ActionResult CTNormalDelete([FromBody] CRUDModel <NetCorePSAV.Models.PSAVCrud.ILCrudModel.Categoria> value) { NetCorePSAV.Models.PSAVCrud.ILCrudModel.Categoria val = new NetCorePSAV.Models.PSAVCrud.ILCrudModel.Categoria(); val.ID = value.Key.ToString(); QueryCrud.UpdateCategories(2, val); CategoriasList.Remove(CategoriasList.Where(or => or.ID == value.Key.ToString()).FirstOrDefault()); return(Json(value)); }
public ActionResult CTNormalUpdate([FromBody] CRUDModel <NetCorePSAV.Models.PSAVCrud.ILCrudModel.Categoria> myObject) { var ord = myObject.Value; NetCorePSAV.Models.PSAVCrud.ILCrudModel.Categoria val = CategoriasList.Where(or => or.ID == ord.ID).FirstOrDefault(); val.ID = ord.ID; val.Nombre = ord.Nombre; QueryCrud.UpdateCategories(1, val); return(Json(myObject.Value)); }
public List <NetCorePSAV.Models.PSAVCrud.ILCrudModel.Categoria> GetCategories() { string TabSQLSens = "SELECT * FROM psav_dev.tc_category"; List <NetCorePSAV.Models.PSAVCrud.ILCrudModel.Categoria> locations = new List <NetCorePSAV.Models.PSAVCrud.ILCrudModel.Categoria>(); 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.ILCrudModel.Categoria location = new NetCorePSAV.Models.PSAVCrud.ILCrudModel.Categoria(); location.ID = sdr.GetValue(0).ToString(); location.Nombre = sdr.GetValue(1).ToString(); locations.Add(location); } conn.Close(); return(locations); }
public string UpdateCategories(int typeUpdate, NetCorePSAV.Models.PSAVCrud.ILCrudModel.Categoria locationModel) { string queryToInsert = ""; string valor = ""; switch (typeUpdate) { case 0: queryToInsert = "insert into psav_dev.tc_category (tcc_name) values('" + locationModel.Nombre + "')"; valor = SaveWithIDReturn(queryToInsert); break; case 1: queryToInsert = "update psav_dev.tc_category set tcc_name='" + locationModel.Nombre + "' where tcc_id=" + locationModel.ID; SaveWithoutValidation(queryToInsert); break; case 2: queryToInsert = "delete from psav_dev.tc_category where tcc_id=" + locationModel.ID; SaveWithoutValidation(queryToInsert); break; } return(valor); }