public async Task <IActionResult> Edit(int id, [Bind("Id,Date,DayOfWeek,Description,CreatedById")] Hollyday hollyday) { if (id != hollyday.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(hollyday); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HollydayExists(hollyday.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CreatedById"] = new SelectList(_context.Employees, "Id", "Id", hollyday.CreatedById); return(View(hollyday)); }
public async Task <IActionResult> Create([Bind("Id,Date,DayOfWeek,Description,CreatedById")] Hollyday hollyday) { if (ModelState.IsValid) { _context.Add(hollyday); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CreatedById"] = new SelectList(_context.Employees, "Id", "Id", hollyday.CreatedById); return(View(hollyday)); }