public ActionResult Delete(string kind, string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (kind == "trgTable") { linkage_trigger trigger = db.linkage_trigger.Find(int.Parse(id)); if (trigger == null) { return(HttpNotFound()); } db.linkage_trigger.Remove(trigger); db.SaveChanges(); } else if (kind == "istrTable") { linkage_instruction instruction = db.linkage_instruction.Find(int.Parse(id)); if (instruction == null) { return(HttpNotFound()); } db.linkage_instruction.Remove(instruction); db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult EditIstr(FormCollection collection) { linkage_instruction istr = new linkage_instruction(); istr.id = int.Parse(collection["id4"]); istr.detail = collection["detail4"]; istr.operation = collection["operation4"]; istr.trigger = collection["trigger4"]; istr.uuid = collection["uuid4"]; db.Entry <linkage_instruction>(istr).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AddIstr(FormCollection collection) { linkage_instruction istr = new linkage_instruction(); //var detailName = collection["detail"]; //LINQ里不能直接用collection[] //var detail = from linkage_algorithm in db.linkage_algorithm // where linkage_algorithm.name == detailName // select linkage_algorithm.value; //var detailList = detail.ToList(); //if(detailList.Count > 0) // istr.detail = detailList[0]; //else // istr.detail = collection["detail"]; //var operationName = collection["operation"]; //LINQ里不能直接用collection[] //var operation = from linkage_operation in db.linkage_operation // where linkage_operation.name == operationName // select linkage_operation.value; //var operationList = operation.ToList(); //istr.operation = operationList[0]; //var triggerName = collection["trigger2"]; //LINQ里不能直接用collection[] //var trigger = from linkage_event in db.linkage_event // where linkage_event.name == triggerName // select linkage_event.value; //var triggerList = trigger.ToList(); //istr.trigger = triggerList[0]; //var uuidName = collection["uuid"]; //LINQ里不能直接用collection[] //var uuid = from device in db.device // where device.alias == uuidName // select device.uuid; //var uuidList = uuid.ToList(); //istr.uuid = uuidList[0]; istr.detail = collection["detail3"]; istr.operation = collection["operation3"]; istr.trigger = collection["trigger3"]; istr.uuid = collection["uuid3"]; db.linkage_instruction.Add(istr); db.SaveChanges(); return(RedirectToAction("Index")); }