public async Task<IActionResult> Edit(int id, [Bind("ID,ProjectType,ProjectName")] MLProject mLProject) { if (id != mLProject.ID) { return NotFound(); } if (!_context.MLProject.Any(proj => proj.ID == id && proj.OwnerId == GetUserID())) return NotFound(); mLProject.OwnerId = GetUserID(); if (ModelState.IsValid) { try { _context.Update(mLProject); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MLProjectExists(mLProject.ID)) { return NotFound(); } else { throw; } } return RedirectToAction(nameof(Index)); } return View(mLProject); }
public async Task<IActionResult> Create([Bind("ID,ProjectType,ProjectName")] MLProject mLProject) { if (ModelState.IsValid) { mLProject.OwnerId = GetUserID(); _context.Add(mLProject); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(mLProject); }