Exemplo n.º 1
0
        public Ingrediente Consultar(int id)
        {
            DaoIngrediente repositorio = new DaoIngrediente();
            Ingrediente    ingrediente = repositorio.Consultar(id);

            if (ingrediente == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(ingrediente);
        }
Exemplo n.º 2
0
        public HttpResponseMessage Incluir(Ingrediente ingrediente)
        {
            DaoIngrediente repositorio = new DaoIngrediente();

            ingrediente.Id = repositorio.Incluir(ingrediente);
            HttpResponseMessage response = base.Request.CreateResponse(HttpStatusCode.Created, ingrediente);
            string uri = base.Url.Link("DefaultApi", new { id = ingrediente.Id });

            response.Headers.Location = new Uri(uri);
            return(response);
        }
Exemplo n.º 3
0
        public void Excluir(int id)
        {
            DaoIngrediente repositorio = new DaoIngrediente();

            try
            {
                repositorio.Excluir(id);
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
        }
Exemplo n.º 4
0
        public void Alterar(Ingrediente ingrediente)
        {
            DaoIngrediente repositorio = new DaoIngrediente();

            try
            {
                int resposta = repositorio.Alterar(ingrediente);
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
        }
Exemplo n.º 5
0
        public IEnumerable <Ingrediente> Listar()
        {
            DaoIngrediente repositorio = new DaoIngrediente();

            return(repositorio.Listar());
        }