Exemple #1
0
        public IActionResult AtualizaNome([FromBody] ItemV itemV, long id)
        {
            try
            {
                if (id <= 0)
                {
                    return(StatusCode(400, new ErrorClass(400, "Codigo Invalido", DateTime.Now)));
                }
                var item = (Item.FindById(id));
                if (item == null)
                {
                    return(StatusCode(404, new ErrorClass(404, "Sensor não encontrado", DateTime.Now)));
                }
                item.ChangeName(itemV.Nome);
                item.UpdateItem();

                return(StatusCode(200, _converter.Parser(item)));
            }
            catch (MercurioCoreException ex)
            {
                return(StatusCode(400, new ErrorClass(400, ex.Message, DateTime.Now)));
            }
            catch (DBConnectionException ex)
            {
                return(StatusCode(500, new ErrorClass(500, ex.Message, DateTime.Now)));
            }
        }
Exemple #2
0
 public IActionResult CreateItem([FromBody] ItemV item)
 {
     try
     {
         Item i = _converter.Parser(item);
         i.CreateItem();
         return(Ok(_converter.Parser(i)));
     }
     catch (MercurioCoreException ex)
     {
         return(StatusCode(400, new ErrorClass(400, ex.Message, DateTime.Now)));
     }
     catch (DBConnectionException ex)
     {
         return(StatusCode(500, new ErrorClass(500, ex.Message, DateTime.Now)));
     }
 }