public async Task <IActionResult> Edit(Guid id, [Bind("ExpenseCategoryID,AccountsID,Amount,Date,Remarks,ID")] ExpenseHistory expenseHistory)
        {
            if (id != expenseHistory.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(expenseHistory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExpenseHistoryExists(expenseHistory.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AccountsID"]        = new SelectList(_context.Accounts.OrderBy(x => x.AccountName), "ID", "AccountName", expenseHistory.AccountsID);
            ViewData["ExpenseCategoryID"] = new SelectList(_context.ExpenseCategory.OrderBy(x => x.Name), "ID", "Name", expenseHistory.ExpenseCategoryID);
            return(View(expenseHistory));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("AccountName,ID")] Accounts accounts)
        {
            if (id != accounts.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accounts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountsExists(accounts.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(accounts));
        }
Exemple #3
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Name,ID")] ExpenseCategory expenseCategory)
        {
            if (id != expenseCategory.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(expenseCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExpenseCategoryExists(expenseCategory.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(expenseCategory));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("PersonName,Amount,Remarks,ID")] LoanInfo loanInfo)
        {
            if (id != loanInfo.ID)
            {
                return(NotFound());
            }

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