public async Task <IActionResult> Register(RegisterUserViewModel touristInfo)
        {
            if (ModelState.IsValid)
            {
                return(View(touristInfo));
            }
            string       username = touristInfo.Email;
            IdentityUser user     = await _userManager.FindByNameAsync(username);

            if (user != null)
            {
                ModelState.AddModelError("Email", "There is already a tourist with that email");
                return(View(touristInfo));
            }
            user = new IdentityUser(username);
            await _userManager.CreateAsync(user, touristInfo.Password);

            await _userManager.AddToRoleAsync(user, "Tourist");

            Tourist tourist = new Tourist
            {
                Nome  = touristInfo.Nome,
                Email = touristInfo.Email
            };

            _ = _context.Add(tourist);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index), "Home"));
        }
        public async Task <IActionResult> Create([Bind("Reserva_MesaId,Numero,Data_Reserva,Hora_Reserva,Pessoas")] Reserva_Mesa reserva_Mesa)
        {
            if (ModelState.IsValid)
            {
                _context.Add(reserva_Mesa);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(reserva_Mesa));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("EventoId,Nome,Localizacao,Descricao,Entrada")] Evento evento)
        {
            if (ModelState.IsValid)
            {
                _context.Add(evento);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(evento));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create([Bind("TakeAwayID,Request,Description")] TakeAway takeAway)
        {
            if (ModelState.IsValid)
            {
                _context.Add(takeAway);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(takeAway));
        }
        public async Task <IActionResult> Create([Bind("MesaId,Numero,Restaurante,Lugares")] Mesa mesa)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mesa);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(mesa));
        }
Esempio n. 6
0
        public async Task <IActionResult> Create([Bind("PratoID,Name,Description,Preco,Alergénicos,RestauranteId")] Prato prato)
        {
            if (ModelState.IsValid)
            {
                _context.Add(prato);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(prato));
        }
        public async Task <IActionResult> Create([Bind("RestaurantesId,Name,Description,Contact,Email,Location,LimitMax")] Restaurantes restaurantes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(restaurantes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(restaurantes));
        }