public string PiSendLOG(String userID, String deviceID) { if (!String.IsNullOrEmpty(deviceID)) { Device device = db.Devices.Find(deviceID); if (device == null || device.device_status == 1) { return("log_fail"); } } try { //Log Attent atten = new Attent() { attent_device = deviceID, attent_user = userID, attent_time = DateTime.Now, attent_type = 0 }; db.Attents.Add(atten); db.SaveChanges(); } catch { return("log_fail"); } //save LOG to DB return("OK"); //return "LOG_fail"; }
public ActionResult DeleteConfirmed(string id) { Attent attent = db.Attents.Find(id); db.Attents.Remove(attent); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "log_id,user_id,log_time,device_id,log_type,description")] Attent attent) { if (ModelState.IsValid) { db.Entry(attent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(attent)); }
public ActionResult Create([Bind(Include = "log_id,user_id,log_time,device_id,log_type,description")] Attent attent) { if (ModelState.IsValid) { db.Attents.Add(attent); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(attent)); }
// GET: Attents/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Attent attent = db.Attents.Find(id); if (attent == null) { return(HttpNotFound()); } return(View(attent)); }