예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("DificuldadeId,NomeDificuldade,Observacoes")] Dificuldade dificuldade)
        {
            if (id != dificuldade.DificuldadeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dificuldade);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DificuldadeExists(dificuldade.DificuldadeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dificuldade));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("TrilhoId,Tempo_Gasto,TuristaId,Data_Reserva,Data_Prevista_Inicio_Trilho,Estado_Agendamento,Data_Estado_Agendamento")] Agenda_Turista_Trilho agenda_Turista_Trilho)
        {
            //agenda_Turista_Trilho.Turista = await _context.Turista.SingleOrDefaultAsync(t => t.TuristaId == 1);
            //agenda_Turista_Trilho.Dificuldade = await _context.Dificuldade.SingleOrDefaultAsync(d => d.DificuldadeId == 1);
            if (id != agenda_Turista_Trilho.Agenda_Turista_TrilhoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(agenda_Turista_Trilho);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Agenda_Turista_TrilhoExists(agenda_Turista_Trilho.Agenda_Turista_TrilhoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["TrilhoId"]  = new SelectList(_context.Set <Trilho>(), "TrilhoId", "Nome", agenda_Turista_Trilho.TrilhoId);
            ViewData["TuristaId"] = new SelectList(_context.Set <Turista>(), "TuristaId", "Nome", agenda_Turista_Trilho.TuristaId);
            return(View(agenda_Turista_Trilho));
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("TrilhoId,Nome_Trilho,Local_Inicio_Trilho,Local_Fim_Trilho,Distancia_Total,Duracao_Media,Esta_Ativo,Tempo_Gasto,ProfessorId,DificuldadeId")] Trilho trilho)
        {
            if (id != trilho.TrilhoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(trilho);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TrilhoExists(trilho.TrilhoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["DificuldadeId"] = new SelectList(_context.Set <Dificuldade>(), "DificuldadeId", "DificuldadeId", trilho.DificuldadeId);
            ViewData["ProfessorId"]   = new SelectList(_context.Professor, "ProfessorId", "DataNascimento", trilho.ProfessorId);
            return(View(trilho));
        }
예제 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ProfessorId,Nome,Password,Morada,CodPostal,Email,Telemovel,DataNascimento,NIF,Funcao,N_Gabinete")] Professor professor)
        {
            if (id != professor.ProfessorId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(professor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProfessorExists(professor.ProfessorId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(professor));
        }
예제 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Email, Password, ConfirmPassword, TuristaId, Nome, Morada,CodPostal,Email,Telemovel,DataNascimento,NIF")] Turista turista)
        {
            if (id != turista.TuristaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                if (IsValidContrib(turista.NIF) == false)
                {
                    ModelState.AddModelError("NIF", "O Nif está incorreto.");
                    return(View());
                }
                else
                {
                    try
                    {
                        _context.Update(turista);
                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (!TuristaExists(turista.TuristaId))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }
                    return(RedirectToAction("Index"));
                }
            }
            return(View(turista));
        }