Exemplo n.º 1
0
 public IHttpActionResult DeletePerson(int id)
 {
     DAB4.Models.SmartGrid p = _smartGrids.Get(id);
     if (p != null)
     {
         _smartGrids.Remove(p);
         return(StatusCode(HttpStatusCode.NoContent));
     }
     return(NotFound());
 }
Exemplo n.º 2
0
        public IHttpActionResult Post(int id, DAB4.Models.SmartGrid smartGrid)
        {
            if (_smartGridRepository.Get(id) != null)
            {
                return(StatusCode(HttpStatusCode.NotAcceptable));
            }


            _smartGridRepository.Add(smartGrid);
            return(StatusCode(HttpStatusCode.Accepted));
        }
Exemplo n.º 3
0
        public IHttpActionResult PutPerson(int id, DAB4.Models.SmartGrid grid)
        {
            DAB4.Models.SmartGrid newPerson = _smartGrids.ReplaceSmartGridDocument(id, grid);

            if (newPerson == null)
            {
                return(NotFound());
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 4
0
        public IHttpActionResult GetPerson(int id)
        {
            DAB4.Models.SmartGrid s = _smartGrids.Get(id);

            if (s == null)
            {
                return(NotFound());
            }

            return(Ok(s));
        }
Exemplo n.º 5
0
        public IHttpActionResult PostPerson(DAB4.Models.SmartGrid grid)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            try
            {
                _smartGrids.Add(grid);
            }
            catch (Exception e)
            {
                return(BadRequest());
            }

            return(CreatedAtRoute("DefaultApi", new { id = grid.Id }, grid));
        }