Exemplo n.º 1
0
        public void Delete(int id)
        {
            Mapper_Category delete = new Mapper_Category();

            delete.Model = delete.Load(id);
            delete.Delete();
        }
Exemplo n.º 2
0
        public IHttpActionResult Get(int id)
        {
            Mapper_Category mapper  = new Mapper_Category();
            Category        retorno = (Category)mapper.Load(id);

            return(ResponseMessage(Request.CreateResponse <Object>(HttpStatusCode.OK, retorno)));
        }
Exemplo n.º 3
0
        // GET: api/User
        public IHttpActionResult Get()
        {
            Mapper_Category  mapper  = new Mapper_Category();
            IList <Category> retorno = mapper.GetAll();

            return(ResponseMessage(Request.CreateResponse <Object>(HttpStatusCode.OK, retorno)));
        }
Exemplo n.º 4
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.º 5
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)));
            }
        }