public MsgDriverForApp(MsgDriver x) { this.BusID = x.BusID; this.DriverID = x.DriverID; this.MsgDriverID = x.MsgDriverID; this.Text = x.Text; this.TimeStamp = x.TimeStamp; }
public ActionResult getMessageFromDriver() { MsgDriver receivedMessage = new MsgDriver(); try { Request.InputStream.Position = 0; var jsonString = new System.IO.StreamReader(Request.InputStream).ReadToEnd(); JavaScriptSerializer js = new JavaScriptSerializer(); receivedMessage = js.Deserialize<MsgDriver>(jsonString); receivedMessage.Status = Status.Unread; receivedMessage.Receiver = Receiver.Provider; receivedMessage.Bus = db.Buses.Find(receivedMessage.BusID); receivedMessage.Driver = db.Drivers.Find(receivedMessage.DriverID); db.MsgDrivers.Add(receivedMessage); db.SaveChanges(); String message = "DONE"; // change this value to some global constant return Json(message, JsonRequestBehavior.AllowGet); } catch (Exception ex) { // Creation failed String message = "FAIL"; // change this value to some global constant return Json(message, JsonRequestBehavior.AllowGet); } }