public async Task <IActionResult> Create([Bind("Id,Name,Email")] UserAccount userAccount) { if (ModelState.IsValid) { _context.Add(userAccount); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(userAccount)); }
public async Task <IActionResult> Create([Bind("Id,Description,Amount,Date")] ExpenseRecord expenseRecord) { if (ModelState.IsValid) { var user = (from account in _context.UserAccount where account.Email.Equals(User.Identity.Name) select account).FirstOrDefault(); expenseRecord.UserAccountId = user.Id; _context.Add(expenseRecord); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(expenseRecord)); }
public async Task <IActionResult> DeleteConfirmed(int id) { var montlyExpenseReport = await _context.MontlyExpenseReport.FindAsync(id); _context.MontlyExpenseReport.Remove(montlyExpenseReport); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }