public async Task <IActionResult> Edit(int id, [Bind("SchoolID,Quarter,Year,ProjectYear,Date,VisitorName,ReCollectData,Verified,VerifiedBy,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate")] Tool5 tool5) { if (id != tool5.SchoolID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tool5); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Tool5Exists(tool5.SchoolID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SchoolID"] = new SelectList(_context.Schools, "SchoolID", "SName", tool5.SchoolID); return(View(tool5)); }
public async Task <IActionResult> Create([Bind("SchoolID,Quarter,Year,ProjectYear,Date,VisitorName,ReCollectData,Verified,VerifiedBy,CreatedBy,CreatedDate,UpdatedBy,UpdatedDate")] Tool5 tool5) { //Identify Duplicate var t5 = _context.Tool5.Where(a => a.SchoolID == tool5.SchoolID && a.Quarter == tool5.Quarter); if (t5.Any()) { ModelState.AddModelError("", "Recored Already Exist against this school in Quarter " + tool5.Quarter); return(View(tool5)); } if (ModelState.IsValid) { tool5.CreatedBy = User.Identity.Name; tool5.CreatedDate = DateTime.Now.Date; _context.Add(tool5); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); return(RedirectToAction("Create", "Tool5Detail", new { id = tool5.SchoolID, q = tool5.Quarter })); } ViewData["SchoolID"] = new SelectList(_context.Schools, "SchoolID", "SName", tool5.SchoolID); return(View(tool5)); }