コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,ProgramID,Title")] ProgramWeek programWeek)
        {
            if (id != programWeek.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(programWeek);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProgramWeekExists(programWeek.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(programWeek));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("ID,ProgramID,Title")] ProgramWeek programWeek)
        {
            if (ModelState.IsValid)
            {
                _context.Add(programWeek);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(programWeek));
        }
コード例 #3
0
        private void CreateProgramWeeksForProgram(int numberOfWeeks, int programID, int startingNumberOfWeeks = 1)
        {
            int i = startingNumberOfWeeks;

            for (i = startingNumberOfWeeks; i <= numberOfWeeks; i++)
            {
                ProgramWeek week = new ProgramWeek();
                week.ProgramID       = programID;
                week.Title           = "Week " + i;
                week.WeekSequenceNum = i;

                _context.Add(week);
            }
        }