public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Hours,ProjectId")] HoursSpent hoursSpent) { if (id != hoursSpent.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(hoursSpent); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HoursSpentExists(hoursSpent.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProjectId"] = new SelectList(_context.Projects, "Id", "Id", hoursSpent.ProjectId); return(View(hoursSpent)); }
public async Task <IActionResult> Create([Bind("Id,Name,Hours,ProjectId")] HoursSpent hoursSpent) { if (ModelState.IsValid) { _context.Add(hoursSpent); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProjectId"] = new SelectList(_context.Projects, "Id", "Id", hoursSpent.ProjectId); return(View(hoursSpent)); }