Ejemplo n.º 1
0
        public IHttpActionResult PutPedidoModel([FromBody] PedidoModel pedidoModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (pedidoModel.Entrega != null && pedidoModel.Entrega.idEntrega != pedidoModel.idEntrega)
            {
                var entrega = db.MovimientosModels.Where(x => x.idEntrega == pedidoModel.idEntrega).FirstOrDefault();
                pedidoModel.Entrega = entrega;
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(BadRequest(ex.Message));
            }

            return(StatusCode(HttpStatusCode.OK));
        }
Ejemplo n.º 2
0
        public IHttpActionResult PutBarrilModel([FromBody] BarrilModel barrilModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //if (id != barrilModel.id)
            //{
            //    return BadRequest();
            //}

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(BadRequest(ex.Message));
            }

            return(StatusCode(HttpStatusCode.OK));
        }
Ejemplo n.º 3
0
        public IHttpActionResult PutEstilosModel(EstilosModel estilosModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //if (id != estilosModel.IdEstilo)
            //{
            //    return BadRequest();
            //}

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(BadRequest(ex.Message));
                //if (!EstilosModelExists(id))
                //{
                //    return NotFound();
                //}
                //else
                //{
                //    throw;
                //}
            }

            return(StatusCode(HttpStatusCode.OK));
        }
        public IHttpActionResult PutDetallesMovimientosModel(long id, DetallesMovimientosModel detallesMovimientosModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 5
0
        public IHttpActionResult PutRecetaModel([FromBody] RecetaModel recetaModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(BadRequest(ex.Message));
            }

            return(StatusCode(HttpStatusCode.OK));
        }
Ejemplo n.º 6
0
        public bool ValidateToken(string tokenId)
        {
            var token = db.TokenModels.Where(t => t.AuthToken == tokenId && t.ExpiresOn > DateTime.Now).FirstOrDefault();

            if (token != null && !(DateTime.Now > token.ExpiresOn))
            {
                token.ExpiresOn = token.ExpiresOn.AddSeconds(
                    Convert.ToDouble(ConfigurationManager.AppSettings["AuthTokenExpiry"]));
                db.Entry(token).State = EntityState.Modified;
                db.SaveChanges();
                return(true);
            }
            return(false);
        }
Ejemplo n.º 7
0
        public IHttpActionResult PutProductoModel([FromBody] ProductoModel productoModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(Ok());
        }