Exemple #1
0
        public IHttpActionResult Postrq_operaciones(rq_operaciones rqOperaciones)
        {
            tracer.Debug(Request, this.ControllerContext.ControllerDescriptor.ControllerType.FullName, "URI: " + Request.RequestUri);
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            int operaciones_guardadas = 0;

            try
            {
                db.rq_operaciones.Add(rqOperaciones);
                operaciones_guardadas = db.SaveChanges();
                tracer.Debug(Request, this.ControllerContext.ControllerDescriptor.ControllerType.FullName, "Operaciones guardadas: " + operaciones_guardadas);
            }
            catch (System.Exception ex)
            {
                tracer.Error(Request, this.ControllerContext.ControllerDescriptor.ControllerType.FullName, "Operacion de BBDD fallida: " + ex.Message);
                throw;
            }

            if (operaciones_guardadas == 0)
            {
                tracer.Warn(Request, this.ControllerContext.ControllerDescriptor.ControllerType.FullName, "Operacion SaveChanges sin exito: " + operaciones_guardadas);
                return(BadRequest(ModelState));
            }
            else
            {
                return(CreatedAtRoute("DefaultApi", new { id = rqOperaciones.ID_Operacion }, rqOperaciones));
            }
        }
Exemple #2
0
        public IHttpActionResult Putrq_operaciones(long id, rq_operaciones rqOperaciones)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != rqOperaciones.ID_Operacion)
            {
                return(BadRequest());
            }

            db.Entry(rqOperaciones).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!rq_operacionesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
        public IHttpActionResult Getrq_operaciones(long id)
        {
            rq_operaciones rqOperaciones = db.rq_operaciones.Find(id);

            if (rqOperaciones == null)
            {
                return(NotFound());
            }

            return(Ok(rqOperaciones));
        }
Exemple #4
0
        public IHttpActionResult Deleterq_operaciones(long id)
        {
            rq_operaciones rqOperaciones = db.rq_operaciones.Find(id);

            if (rqOperaciones == null)
            {
                return(NotFound());
            }

            //TODO : gestionar el acceso a BBDD con try catch
            db.rq_operaciones.Remove(rqOperaciones);
            db.SaveChanges();

            return(Ok(rqOperaciones));
        }