public async Task <IActionResult> Edit(int id, [Bind("RefSchoolClusterId,SchoolClusterCode,SchoolCluster,RefLocationId")] RefSchoolCluster refSchoolCluster) { if (id != refSchoolCluster.RefSchoolClusterId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(refSchoolCluster); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RefSchoolClusterExists(refSchoolCluster.RefSchoolClusterId)) { return(NotFound()); } else { throw; } } TempData["messageType"] = "success"; TempData["messageTitle"] = "RECORD UPDATED"; TempData["message"] = "Record successfully updated"; return(RedirectToAction(nameof(Index))); } ViewData["RefLocationId"] = new SelectList(_context.Locations, "RefLocationId", "RefLocationId", refSchoolCluster.RefLocationId); return(View(refSchoolCluster)); }
public async Task <IActionResult> Create([Bind("RefSchoolClusterId,SchoolClusterCode,SchoolCluster,RefLocationId")] RefSchoolCluster refSchoolCluster) { if (ModelState.IsValid) { _context.Add(refSchoolCluster); await _context.SaveChangesAsync(); TempData["messageType"] = "success"; TempData["messageTitle"] = "RECORD CREATED"; TempData["message"] = "New record successfully created"; return(RedirectToAction(nameof(Index))); } ViewData["RefLocationId"] = new SelectList(_context.Locations, "RefLocationId", "RefLocationId", refSchoolCluster.RefLocationId); return(View(refSchoolCluster)); }