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

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

            try
            {
                ConceptoService service = (ConceptoService) new ConceptoService().setDatabase(db);
                Concepto        c       = service.find(id);
                service.delete(id);

                if (c.Estado == "D")
                {
                    response = this.getSuccessResponse(c);
                }
                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);
        }
Exemplo n.º 2
0
        // GET api/Concepto/5
        public HttpResponseMessage GetConcepto(long id)
        {
            HttpResponseMessage response;

            try
            {
                ConceptoService service = (ConceptoService) new ConceptoService().setDatabase(db);
                Concepto        c       = service.find(id);



                response = this.getSuccessResponse(c);
            }
            catch (Exception e)
            {
                response = this.getErrorResponse(e);
            }
            return(response);
        }
Exemplo n.º 3
0
        // GET api/Concepto
        public HttpResponseMessage Get()
        {
            HttpResponseMessage response;

            try
            {
                ConceptoService service   = (ConceptoService) new ConceptoService().setDatabase(db);
                List <Concepto> conceptos = service.getAll();



                response = this.getSuccessResponse(conceptos);
            }
            catch (Exception e)
            {
                response = this.getErrorResponse(e);
            }
            return(response);
        }
Exemplo n.º 4
0
        // POST api/Concepto
        public HttpResponseMessage Post([FromBody] Concepto c)
        {
            HttpResponseMessage response;

            try
            {
                ConceptoService service = (ConceptoService) new ConceptoService().setDatabase(db);
                c.FechaAlta   = DateTime.Today;
                c.UsuarioAlta = 1;
                c.Estado      = "A";
                c             = service.saveOrUpdate(c);

                response = this.getSuccessResponse(c);
            }
            catch (Exception e)
            {
                response = this.getErrorResponse(e);
            }
            return(response);
        }
Exemplo n.º 5
0
        public IActionResult GetConceptosFacturas(int id)
        {
            var res            = new Dictionary <string, Object>();
            var conceptoServce = new ConceptoService();

            try
            {
                res = conceptoServce.GetConceptosFactura(id);
                return(Ok(res));
            }
            catch (Exception e)
            {
                if (e is NotFoundException)
                {
                    res.Add("message", e.Message);
                    return(NotFound(res));
                }
                res.Add("message", "Error en el servidor");
                return(StatusCode(500, res));
            }
        }
Exemplo n.º 6
0
 public ConceptosController(DataContext context)
 {
     _context         = context;
     _conceptoService = new ConceptoService(_context);
 }