public ActionResult Edit(Message message) { if (ModelState.IsValid) { db.Messages.Attach(message); db.ObjectStateManager.ChangeObjectState(message, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.StationID = new SelectList(db.Stations, "StationID", "Name", message.StationID); return View(message); }
public ActionResult Create(Message message) { if (ModelState.IsValid) { db.Messages.AddObject(message); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.StationID = new SelectList(db.Stations, "StationID", "Name", message.StationID); return View(message); }
public bool CaptureScreenShot(long stationID) { try { var container = new eAdEntities(); var station = (from s in container.Stations where s.StationID == stationID select s).FirstOrDefault<Station>(); if (station != null) { station.Available = true; var entity = new Message { StationID = stationID, Text = "", Command = "Screenshot", Type = "Status", UserID = 1L, DateAdded = DateTime.Now }; container.Messages.AddObject(entity); container.SaveChanges(); } } catch (Exception) { return false; } return true; }
/// <summary> /// Deprecated Method for adding a new object to the Messages EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToMessages(Message message) { base.AddObject("Messages", message); }
/// <summary> /// Create a new Message object. /// </summary> /// <param name="messageID">Initial value of the MessageID property.</param> /// <param name="type">Initial value of the Type property.</param> /// <param name="sent">Initial value of the Sent property.</param> /// <param name="stationID">Initial value of the StationID property.</param> /// <param name="userID">Initial value of the UserID property.</param> /// <param name="command">Initial value of the Command property.</param> public static Message CreateMessage(global::System.Int64 messageID, global::System.String type, global::System.Boolean sent, global::System.Int64 stationID, global::System.Int64 userID, global::System.String command) { Message message = new Message(); message.MessageID = messageID; message.Type = type; message.Sent = sent; message.StationID = stationID; message.UserID = userID; message.Command = command; return message; }
public bool SendMessageToStation(long stationID, MessageViewModel message) { try { var container = new eAdEntities(); var station = (from s in container.Stations where s.StationID == stationID select s).FirstOrDefault<Station>(); if (station != null) { station.Available = false; var entity = new Message { StationID = station.StationID, DateAdded = DateTime.Now, Text = message.Text, Command = message.Command, Type = message.Type, UserID = message.UserID }; container.Messages.AddObject(entity); } container.SaveChanges(); } catch (Exception) { return false; } return true; }
public bool SendMessageToGroup(long groupID, MessageViewModel message) { try { var container = new eAdEntities(); var grouping = (from s in container.Groupings where s.GroupingID == groupID select s).FirstOrDefault<Grouping>(); if (grouping != null) { foreach (Station station in grouping.Stations) { station.Available = false; var entity = new Message { DateAdded = DateTime.Now, StationID = station.StationID, Text = message.Text, Command = message.Command, Type = message.Type, UserID = message.UserID }; container.Messages.AddObject(entity); } } container.SaveChanges(); } catch (Exception) { return false; } return true; }
public bool MakeStationUnAvailable(long stationID, string rfidCode = "") { try { var container = new eAdEntities(); var station = (from s in container.Stations where s.StationID == stationID select s).FirstOrDefault<Station>(); if (station != null) { station.Available = false; var entity = new Message { StationID = stationID, Text = rfidCode, Command = "Make UnAvailable", Type = "Status", UserID = 1L, DateAdded = DateTime.Now }; container.Messages.AddObject(entity); container.SaveChanges(); } } catch (Exception) { return false; } return true; }