Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("StartupsId,NewsId")] StartupsNews startupsNews)
        {
            if (id != startupsNews.StartupsId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(startupsNews);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StartupsNewsExists(startupsNews.StartupsId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NewsId"]     = new SelectList(_context.News, "Id", "Id", startupsNews.NewsId);
            ViewData["StartupsId"] = new SelectList(_context.Startups, "Id", "Id", startupsNews.StartupsId);
            return(View(startupsNews));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("StartupsId,NewsId")] StartupsNews startupsNews)
        {
            if (ModelState.IsValid)
            {
                _context.Add(startupsNews);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["NewsId"]     = new SelectList(_context.News, "Id", "Id", startupsNews.NewsId);
            ViewData["StartupsId"] = new SelectList(_context.Startups, "Id", "Id", startupsNews.StartupsId);
            return(View(startupsNews));
        }