public async Task <IActionResult> Delete(int?id)
        {
            var carrito = await _context.Carrito.FindAsync(id);

            _context.Remove(carrito);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(string nombre, string apellido, int idUser)
        {
            Usuario usuario = await _context.Usuario.FirstOrDefaultAsync(x => x.IdUsuario == idUser);

            usuario.Nombre   = nombre;
            usuario.Apellido = apellido;
            _context.Update(usuario);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Edit(Usuario usuario)
        {
            if (ModelState.IsValid)
            {
                _context.Update(usuario);
                await _context.SaveChangesAsync();

                return(View("Cuenta"));
            }

            return(RedirectToAction("Cuenta"));
        }
        public async Task <IActionResult> Create([Bind("IdProducto,Nombre,Descripcion,Precio,Stock,Foto,IdCategoria")] Producto producto)
        {
            if (ModelState.IsValid)
            {
                _context.Add(producto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoriaNombre"] = new SelectList(_context.Categoria, "IdCategoria", "Nombre",
                                                         producto.IdCategoria);
            return(View(producto));
        }
        public async Task <IActionResult> Manage(Orden orden)
        {
            if (orden.IdStatusOrden != null)
            {
                _context.Entry(orden).Property(o => o.IdStatusOrden).IsModified = true;
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Cambiar(List <IFormFile> foto1 = null, List <IFormFile> foto2 = null, List <IFormFile> foto3 = null)
        {
            //Actiualizacion de la foto 1
            if (foto1.Count != 0)
            {
                Slider slider = new Slider();
                foreach (var item in foto1)
                {
                    if (item.Length > 0)
                    {
                        using (var stream = new MemoryStream())
                        {
                            await item.CopyToAsync(stream);

                            slider.Foto     = stream.ToArray();
                            slider.IdSlider = 1;
                        }
                    }
                }
                _context.Update(slider);
            }

            //Actiualizacion de la foto 2

            if (foto2.Count != 0)
            {
                Slider slider = new Slider();
                foreach (var item in foto2)
                {
                    if (item.Length > 0)
                    {
                        using (var stream = new MemoryStream())
                        {
                            await item.CopyToAsync(stream);

                            slider.Foto     = stream.ToArray();
                            slider.IdSlider = 2;
                        }
                    }
                }
                _context.Update(slider);
            }

            //Actiualizacion de la foto 3

            if (foto3.Count != 0)
            {
                Slider slider = new Slider();
                foreach (var item in foto3)
                {
                    if (item.Length > 0)
                    {
                        using (var stream = new MemoryStream())
                        {
                            await item.CopyToAsync(stream);

                            slider.Foto     = stream.ToArray();
                            slider.IdSlider = 3;
                        }
                    }
                }
                _context.Update(slider);
            }

            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }