public async Task <IActionResult> Create([Bind("Id,Name")] Profession profession)
        {
            if (ModelState.IsValid)
            {
                _context.Add(profession);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(profession));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName")] Trainee trainee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(trainee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(trainee));
        }
        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));
        }