public async Task <IActionResult> EditPersonalData(EditLoggedInTuristaViewModel turista) { if (!ModelState.IsValid) { return(View(turista)); } string email = User.Identity.Name; var turistaLoggedin = await _context.Turista.SingleOrDefaultAsync(c => c.Email == email); if (turistaLoggedin == null) { return(NotFound()); } turistaLoggedin.Nome = turista.Nome; try { _context.Update(turistaLoggedin); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { //todo: show error message throw; } return(RedirectToAction(nameof(Index), "Home")); }
public async Task <IActionResult> Edit(int id, [Bind("ReservaVisitaId,TuristaId,VisitasGuiadasId,DataReserva,NPessoas")] ReservaVisita reservaVisita) { if (id != reservaVisita.ReservaVisitaId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(reservaVisita); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReservaVisitaExists(reservaVisita.ReservaVisitaId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["VisitasGuiadasId"] = new SelectList(_context.Set <VisitasGuiadas>(), "VisitasGuiadasId", "Nome", reservaVisita.VisitasGuiadasId); return(View(reservaVisita)); }
public async Task <IActionResult> Edit(int id, [Bind("VisitasGuiadasId,GuiaId,Nome,DatadaVisita,Descricao,NMaxPessoas,Completo")] VisitasGuiadas visitasGuiadas) { if (id != visitasGuiadas.VisitasGuiadasId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(visitasGuiadas); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VisitasGuiadasExists(visitasGuiadas.VisitasGuiadasId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GuiaId"] = new SelectList(_context.Guia, "GuiaId", "Nome", visitasGuiadas.GuiaId); return(View(visitasGuiadas)); }
public async Task <IActionResult> Edit(int id, [Bind("PontosdeInteresseId,Nome,FreguesiaId,ConcelhoId,Morada,Coordenadas")] PontosdeInteresse pontosdeInteresse) { if (id != pontosdeInteresse.PontosdeInteresseId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pontosdeInteresse); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PontosdeInteresseExists(pontosdeInteresse.PontosdeInteresseId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ConcelhoId"] = new SelectList(_context.Concelho, "ConcelhoId", "Nome", pontosdeInteresse.ConcelhoId); ViewData["FreguesiaId"] = new SelectList(_context.Freguesia, "FreguesiaId", "Nome", pontosdeInteresse.FreguesiaId); return(View(pontosdeInteresse)); }
public async Task <IActionResult> Edit(int id, [Bind("PontosVisitaId,PontosdeInteresseId,VisitasGuiadasId,Ordem")] PontosVisita pontosVisita) { if (id != pontosVisita.PontosVisitaId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pontosVisita); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PontosVisitaExists(pontosVisita.PontosVisitaId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PontosdeInteresseId"] = new SelectList(_context.PontosdeInteresse, "PontosdeInteresseId", "Nome", pontosVisita.PontosdeInteresseId); ViewData["VisitasGuiadasId"] = new SelectList(_context.VisitasGuiadas, "VisitasGuiadasId", "Nome", pontosVisita.VisitasGuiadasId); return(View(pontosVisita)); }
public async Task <IActionResult> Edit(int id, [Bind("FreguesiaId,Nome")] Freguesia freguesia) { if (id != freguesia.FreguesiaId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(freguesia); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FreguesiaExists(freguesia.FreguesiaId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(freguesia)); }
public async Task <IActionResult> Edit(int id, [Bind("ConcelhoId,Nome")] Concelho concelho) { if (id != concelho.ConcelhoId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(concelho); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConcelhoExists(concelho.ConcelhoId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(concelho)); }
public async Task<IActionResult> Edit(int id, [Bind("GuiaId,Nome,Telemovel,Email")] Guia guia, IFormFile photoFile) { if (id != guia.GuiaId) { return NotFound(); } if (ModelState.IsValid) { if (photoFile != null && photoFile.Length > 0) { using (var memFile = new MemoryStream()) { photoFile.CopyTo(memFile); guia.Photo = memFile.ToArray(); } } try { _context.Update(guia); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GuiaExists(guia.GuiaId)) { return NotFound(); } else { throw; } } return RedirectToAction(nameof(Index)); } return View(guia); }