Ejemplo n.º 1
0
        public IHttpActionResult Autenticacion(Request peticion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user     = peticion.Usuario;
            var password = peticion.Password;

            using (var context = new ProductoContext())
            {
                var permitido = context.Requests.Any(x => x.Usuario == user && x.Password == password);
                var response  = new Response();
                response.EsPermitido = permitido;

                if (permitido)
                {
                    response.Mensaje = "OK";
                }
                else
                {
                    response.Mensaje = "No se puede iniciar";
                }

                return(Ok(response));
            }
        }
Ejemplo n.º 2
0
 public IEnumerable <Producto> Get()
 {
     using (var context = new ProductoContext())
     {
         return(context.Productos.ToList());
     }
 }
Ejemplo n.º 3
0
 public IEnumerable <Cliente> Get()
 {
     using (var context = new ProductoContext())
     {
         return(context.Cliente.ToList());
     }
 }
Ejemplo n.º 4
0
 public IEnumerable <Request> Get()
 {
     using (ProductoContext context = new ProductoContext())
     {
         return(context.Requests.ToList());
     }
 }
Ejemplo n.º 5
0
 public Producto Get(int id)
 {
     using (var context = new ProductoContext())
     {
         return(context.Productos.FirstOrDefault(X => X.Id == id));
     }
 }
Ejemplo n.º 6
0
 public Cliente Post(Cliente cliente)
 {
     using (var context = new ProductoContext())
     {
         context.Cliente.Add(cliente);
         context.SaveChanges();
         return(cliente);
     }
 }
Ejemplo n.º 7
0
 public Producto Post(Producto producto)
 {
     using (var context = new ProductoContext())
     {
         context.Productos.Add(producto);
         context.SaveChanges();
         return(producto);
     }
 }
Ejemplo n.º 8
0
        public ProductoContext producto()
        {
            ProductoContext _localctx = new ProductoContext(_ctx, State);

            EnterRule(_localctx, 2, RULE_producto);
            int _la;

            try {
                State = 22;
                _errHandler.Sync(this);
                switch (Interpreter.AdaptivePredict(_input, 1, _ctx))
                {
                case 1:
                    EnterOuterAlt(_localctx, 1);
                    {
                        State = 17; factor();
                        {
                            State = 18;
                            _la   = _input.La(1);
                            if (!(_la == T__2 || _la == T__3))
                            {
                                _errHandler.RecoverInline(this);
                            }
                            else
                            {
                                if (_input.La(1) == TokenConstants.Eof)
                                {
                                    matchedEOF = true;
                                }

                                _errHandler.ReportMatch(this);
                                Consume();
                            }
                            State = 19; producto();
                        }
                    }
                    break;

                case 2:
                    EnterOuterAlt(_localctx, 2);
                    {
                        State = 21; factor();
                    }
                    break;
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                _errHandler.ReportError(this, re);
                _errHandler.Recover(this, re);
            }
            finally {
                ExitRule();
            }
            return(_localctx);
        }
Ejemplo n.º 9
0
 public bool Delete(int Id)
 {
     using (var context = new ProductoContext())
     {
         var productoEliminar = context.Productos.FirstOrDefault(x => x.Id == Id);
         context.Productos.Remove(productoEliminar);
         context.SaveChanges();
         return(true);
     }
 }
Ejemplo n.º 10
0
        public JwtController(IOptions <JwtOptions> jwtOptions, ProductoContext _context)
        {
            _jwtOptions = jwtOptions.Value;
            ThrowIfInvalidOptions(_jwtOptions);
            _serializerSettings = new JsonSerializerSettings

            {
                Formatting = Formatting.Indented
            };
            Context = _context;
        }
        public IEnumerable <Producto> Get()
        {
            using (ProductoContext context = new ProductoContext())
            {
                var listado = context.Productos.ToList();

                //Actualizar la ruta de la imagen
                listado.ForEach(x => x.Imagen = Url.Content(x.Imagen));

                return(listado);
            }
        }
 public IHttpActionResult Post(Producto producto)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     using (var context = new ProductoContext())
     {
         context.Productos.Add(producto);
         context.SaveChanges();
         return(Ok(producto));
     }
 }
Ejemplo n.º 13
0
        public ProductoController(ProductoContext context)
        {
            _context = context;

            if (_context.Productos.Count() == 0)
            {
                _context.Productos.Add(new Producto {
                    nombre      = "Martillo",
                    descripcion = "Sirve para clavar"
                });
                _context.SaveChanges();
            }
        }
Ejemplo n.º 14
0
 public Producto Put(Producto producto)
 {
     using (var context = new ProductoContext())
     {
         var productoActualizar = context.Productos.FirstOrDefault(x => x.Id == producto.Id);
         productoActualizar.Cantidad    = producto.Cantidad;
         productoActualizar.Descripcion = producto.Descripcion;
         productoActualizar.Imagen      = producto.Imagen;
         productoActualizar.Nombre      = producto.Nombre;
         context.SaveChanges();
         return(producto);
     }
 }
Ejemplo n.º 15
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ProductoContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseCors(builder =>
                        builder.WithOrigins("*").AllowAnyHeader().AllowAnyMethod());

            app.UseAuthentication();

            DbInitzializer.Initialize(context);
            app.UseMvc();
        }
Ejemplo n.º 16
0
 public Cliente Put(Cliente cliente)
 {
     using (var context = new ProductoContext())
     {
         var ClienteActualizar = context.Cliente.FirstOrDefault(x => x.Id == cliente.Id);
         ClienteActualizar.Nombres         = cliente.Nombres;
         ClienteActualizar.Apellidos       = cliente.Apellidos;
         ClienteActualizar.Direccion       = cliente.Direccion;
         ClienteActualizar.Celular         = cliente.Celular;
         ClienteActualizar.Estrato         = cliente.Estrato;
         ClienteActualizar.FechaNacimiento = cliente.FechaNacimiento;
         context.SaveChanges();
         return(cliente);
     }
 }
 public bool Put(Producto producto)
 {
     using (var context = new ProductoContext())
     {
         var productoAct = context.Productos.FirstOrDefault(x => x.Id == producto.Id);
         productoAct.Referencia  = producto.Referencia;
         productoAct.Nombre      = producto.Nombre;
         productoAct.Descripcion = producto.Descripcion;
         productoAct.Cantidad    = producto.Cantidad;
         productoAct.Precio      = producto.Precio;
         productoAct.Imagen      = producto.Imagen;
         return(context.SaveChanges() > 0);
         //return producto;
     }
 }
Ejemplo n.º 18
0
        //private CloudStorageAccount storageAccount;


        public ProductoController(ProductoContext contexto, IConfiguration config)
        {
            _contexto          = contexto;
            this.configuration = config;

            /*storageAccount = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(
             * "123459876", "X9XmzmV0xX6AG/WYCXSA8BrrrCF0M4j3X4zFDgJZ5g9hRwPafsIjAWk2kgjLZmj6YSxJGIikJDsLmvxgEfGWTQ=="), true); */

            string connectionString = configuration.GetConnectionString("connectString");

            if (_contexto.Productos.Count() == 0)
            {
                _contexto.Productos.Add(new Producto {
                    Nombre = "Zapatos"
                });
                _contexto.SaveChanges();
            }
        }
Ejemplo n.º 19
0
        private ExprContext expr(int _p)
        {
            ParserRuleContext _parentctx = _ctx;
            int         _parentState     = State;
            ExprContext _localctx        = new ExprContext(_ctx, _parentState);
            ExprContext _prevctx         = _localctx;
            int         _startState      = 2;

            EnterRecursionRule(_localctx, 2, RULE_expr, _p);
            try {
                int _alt;
                EnterOuterAlt(_localctx, 1);
                {
                    State = 22;
                    _errHandler.Sync(this);
                    switch (_input.La(1))
                    {
                    case PARENTESISIZQUIERDO:
                    {
                        _localctx = new ParentesisContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;

                        State = 16; Match(PARENTESISIZQUIERDO);
                        State = 17; expr(0);
                        State = 18; Match(PARENTESISDERECHO);
                    }
                    break;

                    case INDICADOR:
                    {
                        _localctx = new IndicadorContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 20; Match(INDICADOR);
                    }
                    break;

                    case INT:
                    case SEPARADORDECIMAL:
                    {
                        _localctx = new NumeroContext(_localctx);
                        _ctx      = _localctx;
                        _prevctx  = _localctx;
                        State     = 21; num();
                    }
                    break;

                    default:
                        throw new NoViableAltException(this);
                    }
                    _ctx.stop = _input.Lt(-1);
                    State     = 38;
                    _errHandler.Sync(this);
                    _alt = Interpreter.AdaptivePredict(_input, 4, _ctx);
                    while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber)
                    {
                        if (_alt == 1)
                        {
                            if (_parseListeners != null)
                            {
                                TriggerExitRuleEvent();
                            }
                            _prevctx = _localctx;
                            {
                                State = 36;
                                _errHandler.Sync(this);
                                switch (Interpreter.AdaptivePredict(_input, 3, _ctx))
                                {
                                case 1:
                                {
                                    _localctx = new SumaContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 24;
                                    if (!(Precpred(_ctx, 7)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(_ctx, 7)");
                                    }
                                    State = 25; Match(MAS);
                                    State = 26; expr(8);
                                }
                                break;

                                case 2:
                                {
                                    _localctx = new RestaContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 27;
                                    if (!(Precpred(_ctx, 6)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(_ctx, 6)");
                                    }
                                    State = 28; Match(MENOS);
                                    State = 29; expr(7);
                                }
                                break;

                                case 3:
                                {
                                    _localctx = new ProductoContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 30;
                                    if (!(Precpred(_ctx, 5)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(_ctx, 5)");
                                    }
                                    State = 31; Match(POR);
                                    State = 32; expr(6);
                                }
                                break;

                                case 4:
                                {
                                    _localctx = new DivisionContext(new ExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                    State = 33;
                                    if (!(Precpred(_ctx, 4)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(_ctx, 4)");
                                    }
                                    State = 34; Match(DIVIDIDO);
                                    State = 35; expr(5);
                                }
                                break;
                                }
                            }
                        }
                        State = 40;
                        _errHandler.Sync(this);
                        _alt = Interpreter.AdaptivePredict(_input, 4, _ctx);
                    }
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                _errHandler.ReportError(this, re);
                _errHandler.Recover(this, re);
            }
            finally {
                UnrollRecursionContexts(_parentctx);
            }
            return(_localctx);
        }
Ejemplo n.º 20
0
 public ProductosController(ProductoContext context)
 {
     _context = context;
 }
Ejemplo n.º 21
0
 public ClienteController(ProductoContext clienteContex)
 {
     Context = clienteContex;
 }
Ejemplo n.º 22
0
 public ProductoController(ProductoContext productoContex)
 {
     Context = productoContex;
 }
Ejemplo n.º 23
0
 public CategoriasController(ProductoContext categoriaContex)
 {
     Context = categoriaContex;
 }