Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserAccountId,Description,Amount,Date")] ExpenseRecord expenseRecord)
        {
            if (id != expenseRecord.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(expenseRecord);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExpenseRecordExists(expenseRecord.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserAccountId"] = new SelectList(_context.Set <UserAccount>(), "Id", "Id", expenseRecord.UserAccountId);
            return(View(expenseRecord));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email")] UserAccount userAccount)
        {
            if (id != userAccount.Id)
            {
                return(NotFound());
            }

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