Esempio n. 1
0
        public async Task <IActionResult> Edit(long id, [Bind("CauseId,SupporterId")] CauseSupporter causeSupporter)
        {
            if (id != causeSupporter.SupporterId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(causeSupporter);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CauseSupporterExists(causeSupporter.SupporterId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CauseId"]     = new SelectList(_context.Causes, "Id", "Id", causeSupporter.CauseId);
            ViewData["SupporterId"] = new SelectList(_context.Members, "Id", "Id", causeSupporter.SupporterId);
            return(View(causeSupporter));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("CauseId,SupporterId")] CauseSupporter causeSupporter)
        {
            if (ModelState.IsValid)
            {
                _context.Add(causeSupporter);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CauseId"]     = new SelectList(_context.Causes, "Id", "Id", causeSupporter.CauseId);
            ViewData["SupporterId"] = new SelectList(_context.Members, "Id", "Id", causeSupporter.SupporterId);
            return(View(causeSupporter));
        }