public async Task <IActionResult> EditPersonalData(EditLoggedInTouristViewModel tourist)
        {
            if (!ModelState.IsValid)
            {
                return(View(tourist));
            }

            string email = User.Identity.Name;

            var touristLoggedin = await _context.Tourist.SingleOrDefaultAsync(c => c.Email == email);

            if (touristLoggedin == null)
            {
                return(NotFound());
            }

            touristLoggedin.Nome = tourist.Nome;

            try
            {
                _context.Update(touristLoggedin);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                //todo: show error message

                throw;
            }
            return(RedirectToAction(nameof(Index), "Home"));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Reserva_MesaId,Numero,Data_Reserva,Hora_Reserva,Pessoas")] Reserva_Mesa reserva_Mesa)
        {
            if (id != reserva_Mesa.Reserva_MesaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reserva_Mesa);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Reserva_MesaExists(reserva_Mesa.Reserva_MesaId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reserva_Mesa));
        }
示例#3
0
        public async Task <IActionResult> Edit(int id, [Bind("EventoId,Nome,Localizacao,Descricao,Entrada")] Evento evento)
        {
            if (id != evento.EventoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(evento);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EventoExists(evento.EventoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(evento));
        }
示例#4
0
        public async Task <IActionResult> Edit(int id, [Bind("TakeAwayID,Request,Description")] TakeAway takeAway)
        {
            if (id != takeAway.TakeAwayID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(takeAway);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TakeAwayExists(takeAway.TakeAwayID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(takeAway));
        }
        public async Task <IActionResult> Edit(int id, [Bind("MesaId,Numero,Restaurante,Lugares")] Mesa mesa)
        {
            if (id != mesa.MesaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mesa);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MesaExists(mesa.MesaId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(mesa));
        }
示例#6
0
        public async Task <IActionResult> Edit(int id, [Bind("PratoID,Name,Description,Preco,Alergénicos,RestauranteId")] Prato prato)
        {
            if (id != prato.PratoID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(prato);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PratoExists(prato.PratoID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(prato));
        }
        public async Task <IActionResult> Edit(int id, [Bind("RestaurantesId,Name,Description,Contact,Email,Location,LimitMax")] Restaurantes restaurantes)
        {
            if (id != restaurantes.RestaurantesId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(restaurantes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RestaurantesExists(restaurantes.RestaurantesId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(restaurantes));
        }