Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,OtelAdi,OtelYildizi,SehirId,UlkeId,KategoriId")] Otell otell)
        {
            if (id != otell.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(otell);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OtellExists(otell.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["KategoriId"] = new SelectList(_context.Kategori, "Id", "KategoriAdı", otell.KategoriId);
            ViewData["SehirId"]    = new SelectList(_context.Sehir, "Id", "SehirAdi", otell.SehirId);
            ViewData["UlkeId"]     = new SelectList(_context.Ulke, "Id", "UlkeAd", otell.UlkeId);
            return(View(otell));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,OtelAdi,OtelYildizi,SehirId,UlkeId,KategoriId")] Otell otell)
        {
            if (ModelState.IsValid)
            {
                _context.Add(otell);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["KategoriId"] = new SelectList(_context.Kategori, "Id", "KategoriAdı", otell.KategoriId);
            ViewData["SehirId"]    = new SelectList(_context.Sehir, "Id", "SehirAdi", otell.SehirId);
            ViewData["UlkeId"]     = new SelectList(_context.Ulke, "Id", "UlkeAd", otell.UlkeId);
            return(View(otell));
        }