Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre")] Rol rol)
        {
            if (id != rol.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(rol);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RolExists(rol.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(rol));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre,Descripcion,Precio,Foto,UsuarioId,Disponible")] Producto producto)
        {
            if (id != producto.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(producto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductoExists(producto.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UsuarioId"] = new SelectList(_context.Usuario, "Id", "Apellido", producto.UsuarioId);
            return(View(producto));
        }
Beispiel #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CompradorId,VendedorId")] VendedorFavorito vendedorFavorito)
        {
            if (id != vendedorFavorito.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vendedorFavorito);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VendedorFavoritoExists(vendedorFavorito.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CompradorId"] = new SelectList(_context.Usuario, "Id", "Apellido", vendedorFavorito.CompradorId);
            ViewData["VendedorId"]  = new SelectList(_context.Usuario, "Id", "Apellido", vendedorFavorito.VendedorId);
            return(View(vendedorFavorito));
        }
Beispiel #4
0
        public async Task <IActionResult> Details(int id, [Bind("Id,Nombre,Apellido,Correo,Foto,FileFoto,TipoRolId,Emprendimiento,DescEmprendimiento")] Usuario usuario)
        {
            if (id != usuario.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                if (usuario.FileFoto != null)
                {
                    var stream = new MemoryStream();
                    await usuario.FileFoto.CopyToAsync(stream);

                    usuario.Foto = stream.ToArray();
                }
                //Si no se selecciona foto, se deja la que tenia

                try
                {
                    _context.Update(usuario);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsuarioExists(usuario.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(Details(id).Result);
            }
            return(Details(id).Result);
        }