public async Task <IActionResult> Edit(int id, [Bind("EmployeeHolidayId,EmployeeID,HolidayPeriodID,StartDate,EndDate,Authorised,AuthorisedDate,AuthorisedBy")] EmployeeHoliday employeeHoliday) { if (id != employeeHoliday.EmployeeHolidayId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employeeHoliday); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeHolidayExists(employeeHoliday.EmployeeHolidayId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EmployeeID"] = new SelectList(_context.Employees, "EmployeeID", "FirstName", employeeHoliday.EmployeeID); ViewData["HolidayPeriodID"] = new SelectList(_context.HolidayPeriod, "HolidayPeriodID", "Description", employeeHoliday.HolidayPeriodID); return(View(employeeHoliday)); }
public async Task <IActionResult> Create([Bind("EmployeeHolidayId,EmployeeID,HolidayPeriodID,StartDate,EndDate,Authorised,AuthorisedDate,AuthorisedBy")] EmployeeHoliday employeeHoliday) { if (ModelState.IsValid) { _context.Add(employeeHoliday); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EmployeeID"] = new SelectList(_context.Employees, "EmployeeID", "FirstName", employeeHoliday.EmployeeID); ViewData["HolidayPeriodID"] = new SelectList(_context.HolidayPeriod, "HolidayPeriodID", "Description", employeeHoliday.HolidayPeriodID); return(View(employeeHoliday)); }