Beispiel #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));
        }
        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"));
        }
Beispiel #3
0
        public IHttpActionResult Get(int rows = 1)
        {
            if (rows < 1)
            {
                rows = 1;
            }

            string retRows;

            using (var context = new db_Entities())
            {
                var row = context.temp_fan.ToList().OrderByDescending(r => r.id).Take(rows);
                retRows = JsonConvert.SerializeObject(row);
            }
            logger.Info("Log Get");
            return(Ok(retRows));
        }
Beispiel #4
0
        public IHttpActionResult Get()
        {
            logger.Trace("PiPlates.Get");

            temp_fan row;
            string   jRow = string.Empty;

            using (var context = new db_Entities())
            {
                row  = context.temp_fan.ToList().OrderByDescending(r => r.id).FirstOrDefault();
                jRow = JsonConvert.SerializeObject(row);
            }
            logger.Info("Log Get");
            if (jRow != string.Empty)
            {
                return(Ok(jRow));
            }
            else
            {
                return(Ok("No Row Found"));
            }
        }
        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);
        }