public JsonResult EliminarObjeto(int idObjeto) { OBJETOS objeto = db.ObjetosDB.Find(idObjeto); try { db.ObjetosDB.Remove(objeto); db.SaveChanges(); return(Json(0, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(1, JsonRequestBehavior.AllowGet)); throw; } //var objeto = db.ObjetosDB.Where(x => x.ID_OBJETO == idObjeto).FirstOrDefault(); }
public JsonResult AgregarObjeto(string nombre, string color, DateTime fechaRegistro, decimal precio) { OBJETOS objNuevo = new OBJETOS(); objNuevo.NOMBRE = nombre; objNuevo.COLOR = color; objNuevo.FECHA_REGISTRO = fechaRegistro; objNuevo.PRECIO = precio; try { db.ObjetosDB.Add(objNuevo); db.SaveChanges(); return(Json(0, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(1, JsonRequestBehavior.AllowGet)); throw; } }