public async Task <IActionResult> Register(RegisterTuristaViewModel turistaInfo) { if (!ModelState.IsValid) { return(View(turistaInfo)); } string username = turistaInfo.Email; IdentityUser user = await _userManager.FindByNameAsync(username); if (user != null) { ModelState.AddModelError("Email", "Já foi criada uma conta com este email."); return(View(turistaInfo)); } user = new IdentityUser(username); await _userManager.CreateAsync(user, turistaInfo.Password); await _userManager.AddToRoleAsync(user, "Turista"); Turista turista = new Turista { Nome = turistaInfo.Nome, Telemovel = turistaInfo.Telemovel, Morada = turistaInfo.Morada, NIF = turistaInfo.NIF, Email = turistaInfo.Email }; _context.Add(turista); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), "Home")); }
public async Task <IActionResult> Create([Bind("FreguesiaId,Nome")] Freguesia freguesia) { if (ModelState.IsValid) { _context.Add(freguesia); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(freguesia)); }
public async Task <IActionResult> Create([Bind("ConcelhoId,Nome")] Concelho concelho) { if (ModelState.IsValid) { _context.Add(concelho); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(concelho)); }
public async Task <IActionResult> Create([Bind("TuristaId,VisitasGuiadasId,DataReserva,NPessoas")] ReservaVisita reservaVisita) { if (ModelState.IsValid) { _context.Add(reservaVisita); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["VisitasGuiadasId"] = new SelectList(_context.Set <VisitasGuiadas>(), "VisitasGuiadasId", "Nome", reservaVisita.VisitasGuiadasId); return(View(reservaVisita)); }
public async Task <IActionResult> Create([Bind("VisitasGuiadasId,GuiaId,Nome,DatadaVisita,Descricao,NMaxPessoas,Completo")] VisitasGuiadas visitasGuiadas) { if (ModelState.IsValid) { _context.Add(visitasGuiadas); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GuiaId"] = new SelectList(_context.Guia, "GuiaId", "Nome", visitasGuiadas.GuiaId); return(View(visitasGuiadas)); }
public async Task <IActionResult> Create([Bind("PontosdeInteresseId,Nome,FreguesiaId,ConcelhoId,Morada,Coordenadas")] PontosdeInteresse pontosdeInteresse) { if (ModelState.IsValid) { _context.Add(pontosdeInteresse); await _context.SaveChangesAsync(); 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> Create([Bind("PontosVisitaId,PontosdeInteresseId,VisitasGuiadasId,Ordem")] PontosVisita pontosVisita) { if (ModelState.IsValid) { _context.Add(pontosVisita); await _context.SaveChangesAsync(); 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> Create([Bind("GuiaId,Nome,Telemovel,Email")] Guia guia, IFormFile photoFile) { if (ModelState.IsValid) { if (photoFile != null && photoFile.Length > 0) { using (var memFile = new MemoryStream()) { photoFile.CopyTo(memFile); guia.Photo = memFile.ToArray(); } } _context.Add(guia); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(guia); }