Exemple #1
0
        public async Task <JsonResult> apiEDIT(int identificador, int precio, int modelo, DateTime fecha)
        {
            var auto = await _context.Auto
                       .FirstOrDefaultAsync(a => a.Id == identificador);

            auto.Precio           = precio;
            auto.ModeloId         = modelo;
            auto.FechaAdquisicion = fecha;

            //Falta validacion de backend

            try
            {
                _context.Update(auto);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AutoExists(auto.Id))
                {
                    return(Json(NotFound()));
                }
                else
                {
                    throw;
                }
            }

            return(apiGETUNIQUE(identificador));
        }
        public async Task <JsonResult> apiEDIT(int identificador, string nombre, int marca, string descripcion = "")
        {
            var modelo = await _context.Modelo
                         .FirstOrDefaultAsync(m => m.Id == identificador);

            modelo.Nombre      = nombre;
            modelo.MarcaId     = marca;
            modelo.Descripcion = descripcion;

            //Falta validacion de backend

            try
            {
                _context.Update(modelo);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ModeloExists(modelo.Id))
                {
                    return(Json(NotFound()));
                }
                else
                {
                    throw;
                }
            }

            return(apiGETUNIQUE(identificador));
        }
        public async Task <JsonResult> apiEDIT(int identificador, string nombre)
        {
            var marca = await _context.Marca
                        .FirstOrDefaultAsync(m => m.Id == identificador);

            marca.Nombre = nombre;

            //Falta validacion de backend

            try
            {
                _context.Update(marca);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MarcaExists(marca.Id))
                {
                    return(Json(NotFound()));
                }
                else
                {
                    throw;
                }
            }

            return(await apiGETUNIQUE(identificador));
        }
Exemple #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre")] Cliente cliente)
        {
            if (id != cliente.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cliente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClienteExists(cliente.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
Exemple #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre,Sueldo,PorcentajeComision")] Vendedor vendedor)
        {
            if (id != vendedor.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vendedor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VendedorExists(vendedor.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vendedor));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Fecha,AutoId,ClienteId,VendedorId")] Venta venta)
        {
            if (id != venta.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(venta);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VentaExists(venta.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(venta));
        }