Ejemplo n.º 1
0
        // GET: api/Occurrence
        //public IEnumerable<string> Get()
        //{
        //    return new string[] { "value1", "value2" };
        //}

        //// GET: api/Occurrence/5
        //public string Get(int id)
        //{
        //    return "value";
        //}

        // POST: api/Occurrence
        public IHttpActionResult Post([FromBody] dynamic value)
        {
            using (testeftEntities db = new testeftEntities())
            {
                occurrences o = new occurrences();

                o.station_id = value.station_id;

                o.occurred_when = value.occurred_when;

                foreach (var proc in value.proc)
                {
                    processes p = new processes();

                    p.name = proc;

                    o.processes.Add(p);
                }

                db.occurrences.Add(o);

                db.SaveChanges();

                return(Ok(o.id));
            }
        }
        // DELETE: api/Station/5
        public IHttpActionResult Delete(int id)
        {
            using (testeftEntities db = new testeftEntities())
            {
                db.stations.Remove(db.stations.Find(id));

                db.SaveChanges();

                return(Ok());
            }
        }
        // PUT: api/Station/5
        public IHttpActionResult Put(int id, [FromBody] dynamic value)
        {
            using (testeftEntities db = new testeftEntities())
            {
                stations s = db.stations.Find(id);

                s.is_active = value.is_active;

                db.SaveChanges();

                return(Ok());
            }
        }
        // POST: api/Station
        public IHttpActionResult Post([FromBody] dynamic value)
        {
            using (testeftEntities db = new testeftEntities())
            {
                stations s = new stations();

                s.cnpj = value.cnpj;

                s.company_name = value.company_name;

                s.is_active = true;

                db.stations.Add(s);

                db.SaveChanges();

                return(Ok(s.id));
            }
        }