Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,BeginDate,EndDate,TraineeId")] Traineeship traineeship)
        {
            if (id != traineeship.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(traineeship);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TraineeshipExists(traineeship.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TraineeId"] = new SelectList(_context.Trainees, "Id", "Id", traineeship.TraineeId);
            return(View(traineeship));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Id,BeginDate,EndDate,TraineeId")] Traineeship traineeship)
        {
            if (ModelState.IsValid)
            {
                _context.Add(traineeship);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TraineeId"] = new SelectList(_context.Trainees, "Id", "Id", traineeship.TraineeId);
            return(View(traineeship));
        }