コード例 #1
0
        public async Task <IActionResult> Create([Bind("ProgramId,ProgramName,RefProgramTypeId,Description,Max,Min,RefAttendanceUnitId,HasAssessment,DisplayMarks,RefOrganizationTypeId")] MEL.Entities.Programs.Program program)
        {
            if (ModelState.IsValid)
            {
                _context.Add(program);
                await _context.SaveChangesAsync();

                TempData["messageType"]  = "success";
                TempData["messageTitle"] = "RECORD CREATED";
                TempData["message"]      = "New record successfully created";

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RefAttendanceUnitId"]   = new SelectList(_context.AttendanceUnits, "RefAttendanceUnitId", "AttendanceUnit", program.RefAttendanceUnitId);
            ViewData["RefOrganizationTypeId"] = new SelectList(_context.OrganizationTypes, "RefOrganizationTypeId", "OrganizationType", program.RefOrganizationTypeId);
            ViewData["RefProgramTypeId"]      = new SelectList(_context.ProgramTypes, "RefProgramTypeId", "ProgramType", program.RefProgramTypeId);
            return(View(program));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ProgramId,ProgramName,RefProgramTypeId,RefProgramDeliveryTypeId,Description,Max,Min,RefAttendanceUnitId,HasAssessment,DisplayMarks,RefOrganizationTypeId")] MEL.Entities.Programs.Program program)
        {
            if (id != program.ProgramId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(program);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProgramExists(program.ProgramId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                TempData["messageType"]  = "success";
                TempData["messageTitle"] = "RECORD UPDATED";
                TempData["message"]      = "Record successfully updated";

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RefAttendanceUnitId"]      = new SelectList(_context.AttendanceUnits, "RefAttendanceUnitId", "AttendanceUnit", program.RefAttendanceUnitId);
            ViewData["RefOrganizationTypeId"]    = new SelectList(_context.OrganizationTypes, "RefOrganizationTypeId", "OrganizationType", program.RefOrganizationTypeId);
            ViewData["RefProgramTypeId"]         = new SelectList(_context.ProgramTypes, "RefProgramTypeId", "ProgramType", program.RefProgramTypeId);
            ViewData["RefProgramDeliveryTypeId"] = new SelectList(_context.ProgramDeliveryTypes, "RefProgramDeliveryTypeId", "ProgramDeliveryType");

            return(View(program));
        }