Esempio n. 1
0
        public async Task <IActionResult> Edit(string id, [Bind("Email,Contraseña,Nombre,Puntos")] Cliente cliente)
        {
            if (id != cliente.Email)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cliente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClienteExists(cliente.Email))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Details), "Perfiles1", new { id }));
            }
            return(View(cliente));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,SaleDate,PaidFull")] Sale sale)
        {
            if (id != sale.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sale);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SaleExists(sale.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(sale));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("ClienteId,Nome,TipoCliente,Documento,DataCadastro,Telefone")] Cliente cliente)
        {
            if (id != cliente.ClienteId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cliente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClienteExists(cliente.ClienteId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Name,Lastname,DateSet,Phone")] Client client)
        {
            if (id != client.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(client);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientExists(client.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
Esempio n. 5
0
        public IActionResult Edit(int id, Cancha c)
        {
            if (!ModelState.IsValid)
            {
                return(View(c));
            }

            try
            {
                using (var db = new EmpresaContext())
                {
                    if (c.Importe > 0)
                    {
                        db.Update(c);
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "El importe debe ser positivo");
                        return(View());
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 6
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Make,FuelType,Aspiration,NumDoors,BodyStyle,DriveWheels,EngineLocation,WheelBase,Length,Width,Height,CurbWeight,EngineType,NumCylinders,EngineSize,FuelSystem,Bore,Stroke,CompressionRatio,Horsepower,PeakRpm,CityMpg,HighwayMpg,Price")] Vehicle vehicle)
        {
            if (id != vehicle.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vehicle);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VehicleExists(vehicle.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicle));
        }
Esempio n. 7
0
        public async Task <IActionResult> Edit(int id, [Bind("NroCancha,NombreCancha,Habilitada,Importe")] Cancha cancha)
        {
            if (id != cancha.NroCancha)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (cancha.Importe > 0)
                    {
                        if (_context.Cancha.Any(c => c.NombreCancha == cancha.NombreCancha))
                        {
                            Cancha aux = _context.Cancha.Find(id);
                            if (aux.NombreCancha == cancha.NombreCancha)
                            {
                                //_context.Update(cancha);
                                aux.NombreCancha = cancha.NombreCancha;
                                aux.Habilitada   = cancha.Habilitada;
                                aux.Importe      = cancha.Importe;
                                await _context.SaveChangesAsync();
                            }
                            else
                            {
                                ModelState.AddModelError("", "Ya existe otra cancha con ese nombre");
                                return(View());
                            }
                        }
                        else
                        {
                            _context.Update(cancha);
                            await _context.SaveChangesAsync();
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "El importe debe ser positivo");
                        return(View());
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CanchaExists(cancha.NroCancha))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cancha));
        }
Esempio n. 8
0
        public async Task <IActionResult> Edit(int id, [Bind("NroTurno,EmailCliente,NroCancha,FechaHora")] Turno turno)
        {
            if (id != turno.NroTurno)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Cancha c = _context.Cancha.Find(turno.NroCancha);
                    if (c.Habilitada)
                    {
                        if (TurnoDisponible(turno))
                        {
                            _context.Update(turno);
                            await _context.SaveChangesAsync();

                            ModelState.AddModelError("", "Reserva editada correctamente");
                        }
                        else
                        {
                            ModelState.AddModelError("", "El turno no está disponible");
                            ViewData["EmailCliente"] = new SelectList(_context.Cliente, "Email", "Email", turno.EmailCliente);
                            ViewData["NroCancha"]    = new SelectList(_context.Cancha, "NroCancha", "NombreCancha", turno.NroCancha);
                            return(View());
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Cancha Inhabilitada");
                        ViewData["EmailCliente"] = new SelectList(_context.Cliente, "Email", "Email", turno.EmailCliente);
                        ViewData["NroCancha"]    = new SelectList(_context.Cancha, "NroCancha", "NombreCancha", turno.NroCancha);
                        return(View());
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TurnoExists(turno.NroTurno))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                //return RedirectToAction(nameof(Index));
            }
            ViewData["EmailCliente"] = new SelectList(_context.Cliente, "Email", "Email", turno.EmailCliente);
            ViewData["NroCancha"]    = new SelectList(_context.Cancha, "NroCancha", "NombreCancha", turno.NroCancha);
            return(View(turno));
        }
        public async Task <IActionResult> Edit([Bind("Id,nome,CNPJ,telefone,email,endereco,numero,cidade,bairro,senha")] Empresa empresa)
        {
            int id       = Ok;
            var empresas = await _context.Empresas.FirstOrDefaultAsync(e => (e.email == empresa.email || e.CNPJ == empresa.CNPJ) && e.Id != id);

            if (empresas != null)
            {
                ViewBag.Erro = "Email ou CNPJ já cadastrado!";
            }
            else
            {
                if (id != empresa.Id)
                {
                    return(NotFound());
                }

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