Exemplo n.º 1
0
        public IHttpActionResult Post([FromBody] string request)
        {
            try
            {
                logger.Info("request: " + request);

                var     jss  = new JavaScriptSerializer();
                dynamic data = jss.Deserialize <dynamic>(request);

                temp_fan temp = JsonConvert.DeserializeObject <temp_fan>(request);
                // data["GMT"] = "yyyy-MM-dd hh:mm:ss.ffffff offset"
                var dtCreated = (string)data["GMT"];
                logger.Debug("PiPlateController.Post dtCreated = " + dtCreated);
                int idx = dtCreated.IndexOf('.');
                dtCreated = dtCreated.Substring(0, idx);
                logger.Debug("PiPlateController.Post dtCreated SHORT = " + dtCreated);
                //temp.dt_created = DateTime.ParseExact(dtCreated, "yyyy-MM-dd hh:mm:ss", CultureInfo.InvariantCulture);
                temp.dt_created = DateTime.Parse(dtCreated);
                using (var context = new db_Entities())
                {
                    context.Entry(temp).State = EntityState.Added;
                    context.SaveChanges();
                }

                logger.Info(request);
            }
            catch (Exception ex)
            {
                logger.Info("exception: " + ex.ToString());
            }

            return(Ok(request));
        }
Exemplo n.º 2
0
        public IHttpActionResult Post([FromBody] string requset)
        {
            logger.Trace("request: " + requset);

            //DOOR row;
            using (var context = new db_Entities())
            {
                var row = context.door.ToList().FirstOrDefault();
                row.cmd = true;
                context.SaveChanges();
            }
            return(Ok("WOOT"));
        }
Exemplo n.º 3
0
        public IHttpActionResult Get()
        {
            logger.Trace("request: " + "Get() api/door()");
            string retVal = "{\"door\": \"fasle\"}";

            using (var context = new db_Entities())
            {
                logger.Trace("request: " + "Get() inside context");
                var row = context.door.ToList().FirstOrDefault();
                if (row.cmd == true)
                {
                    row.cmd = false;
                    retVal  = "{\"door\": \"true\"}";
                }
                context.SaveChanges();
            }
            var vv = Json(retVal);

            logger.Trace("Get() api/door retVal: " + retVal);
            return(Json(retVal));
            //return Ok(retVal);
        }