Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }