Exemplo n.º 1
0
        public IHttpActionResult Post([FromBody] Category value)
        {
            try
            {
                Mapper_Category mapper = new Mapper_Category();
                mapper.Validate(value);
                mapper.Model = value;
                mapper.Register();

                return(ResponseMessage(Request.CreateResponse <Object>(HttpStatusCode.OK, mapper.Model)));
            }
            catch (Exception e)
            {
                var retorno = new
                {
                    Erro = e.Message
                };

                return(ResponseMessage(Request.CreateResponse <Object>(HttpStatusCode.OK, retorno)));
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult Put(int id, [FromBody] Category value)
        {
            try
            {
                value.Id = id;
                Mapper_Category update = new Mapper_Category();
                update.Validate(value);
                update.Model = value;
                update.Update();

                return(ResponseMessage(Request.CreateResponse <Object>(HttpStatusCode.OK, update.Model)));
            }
            catch (Exception e)
            {
                var retorno = new
                {
                    Erro = e.Message
                };

                return(ResponseMessage(Request.CreateResponse <Object>(HttpStatusCode.OK, retorno)));
            }
        }