Example #1
0
        // PUT api/<controller>/5
        //public void Put(int id, [FromBody]string value)
        //{
        //}

        // DELETE api/Vendedor/5
        public HttpResponseMessage Delete(long id)
        {
            HttpResponseMessage response;

            try
            {
                VendedorService service = (VendedorService) new VendedorService().setDatabase(db);
                Vendedor        v       = service.find(id);
                service.delete(id);

                if (v.Estado == "D")
                {
                    response = this.getSuccessResponse(v);
                }
                else
                {
                    response = this.getSuccessResponse("No se puede eliminar porque existe una compra o hay stock disponible");
                }
            }
            catch (Exception e)
            {
                response = this.getErrorResponse(e);
            }
            return(response);
        }