Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,PartyA,PartyB,Type,StartDateTime,EndDateTime")] Accountabilities accountabilities)
        {
            if (id != accountabilities.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accountabilities);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountabilitiesExists(accountabilities.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PartyA"] = new SelectList(_context.Parties, "Id", "Name", accountabilities.PartyA);
            ViewData["PartyB"] = new SelectList(_context.Parties, "Id", "Name", accountabilities.PartyB);
            ViewData["Type"]   = new SelectList(_context.AccountabilityTypes, "Id", "Id", accountabilities.Type);
            return(View(accountabilities));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,PartyA,PartyB,Type,StartDateTime,EndDateTime")] Accountabilities accountabilities)
        {
            if (ModelState.IsValid)
            {
                _context.Add(accountabilities);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PartyA"] = new SelectList(_context.Parties, "Id", "Name", accountabilities.PartyA);
            ViewData["PartyB"] = new SelectList(_context.Parties, "Id", "Name", accountabilities.PartyB);
            ViewData["Type"]   = new SelectList(_context.AccountabilityTypes, "Id", "Id", accountabilities.Type);
            return(View(accountabilities));
        }