public ActionResult MLBNormalInsert([FromBody] CRUDModel <NetCorePSAV.Models.PSAVCrud.MotivosLBModel> value) { NetCorePSAV.Models.PSAVCrud.MotivosLBModel val = value.Value; val.ID = QueryCrud.UpdateMLB(0, value.Value); MLBList.Insert(MLBList.Count, val); return(Json(MLBList)); }
public ActionResult MLBNormalDelete([FromBody] CRUDModel <NetCorePSAV.Models.PSAVCrud.MotivosLBModel> value) { NetCorePSAV.Models.PSAVCrud.MotivosLBModel val = new NetCorePSAV.Models.PSAVCrud.MotivosLBModel(); val.ID = value.Key.ToString(); QueryCrud.UpdateMLB(2, val); MLBList.Remove(MLBList.Where(or => or.ID == value.Key.ToString()).FirstOrDefault()); return(Json(value)); }
public ActionResult MLBNormalUpdate([FromBody] CRUDModel <NetCorePSAV.Models.PSAVCrud.MotivosLBModel> myObject) { var ord = myObject.Value; NetCorePSAV.Models.PSAVCrud.MotivosLBModel val = MLBList.Where(or => or.ID == ord.ID).FirstOrDefault(); val.ID = ord.ID; val.Nombre = ord.Nombre; QueryCrud.UpdateMLB(1, val); return(Json(myObject.Value)); }
public List <NetCorePSAV.Models.PSAVCrud.MotivosLBModel> GetMotivos() { string TabSQLSens = "SELECT * FROM psav_dev.tc_motivolb"; List <NetCorePSAV.Models.PSAVCrud.MotivosLBModel> locations = new List <NetCorePSAV.Models.PSAVCrud.MotivosLBModel>(); 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.MotivosLBModel location = new NetCorePSAV.Models.PSAVCrud.MotivosLBModel(); location.ID = sdr.GetValue(0).ToString(); location.Nombre = sdr.GetValue(1).ToString(); locations.Add(location); } conn.Close(); return(locations); }
public string UpdateMLB(int typeUpdate, NetCorePSAV.Models.PSAVCrud.MotivosLBModel locationModel) { string queryToInsert = ""; string valor = ""; switch (typeUpdate) { case 0: queryToInsert = "insert into psav_dev.tc_motivolb (tcmlb_nombre) values('" + locationModel.Nombre + "')"; valor = SaveWithIDReturn(queryToInsert); break; case 1: queryToInsert = "update psav_dev.tc_motivolb set tcmlb_nombre='" + locationModel.Nombre + "' where tcmlb_id=" + locationModel.ID; SaveWithoutValidation(queryToInsert); break; case 2: queryToInsert = "delete from psav_dev.tc_motivolb where tcmlb_id=" + locationModel.ID; SaveWithoutValidation(queryToInsert); break; } return(valor); }