コード例 #1
0
        public async Task <IActionResult> Edit(string id, [Bind("ProfileCode,CompetenceId")] ProfileCompetence profileCompetence)
        {
            if (id != profileCompetence.ProfileCode)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(profileCompetence);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProfileCompetenceExists(profileCompetence.ProfileCode))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CompetenceId"] = new SelectList(_context.Competence, "Id", "Code", profileCompetence.CompetenceId);
            ViewData["ProfileCode"]  = new SelectList(_context.Profile, "Code", "Code", profileCompetence.ProfileCode);
            return(View(profileCompetence));
        }
コード例 #2
0
        public async Task <IActionResult> AddProfileCompetence([Bind("ProfileCode,CompetenceId")] ProfileCompetence profileCompetence)
        {
            if (ModelState.IsValid)
            {
                _context.Add(profileCompetence);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Edit), new { id = profileCompetence.ProfileCode }));
            }
            return(RedirectToAction(nameof(Index)));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("ProfileCode,CompetenceId")] ProfileCompetence profileCompetence)
        {
            if (ModelState.IsValid)
            {
                _context.Add(profileCompetence);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CompetenceId"] = new SelectList(_context.Competence, "Id", "Code", profileCompetence.CompetenceId);
            ViewData["ProfileCode"]  = new SelectList(_context.Profile, "Code", "Code", profileCompetence.ProfileCode);
            return(View(profileCompetence));
        }