Exemple #1
0
        public async Task <IActionResult> Create([Bind("ID,Name")] Skill skill)
        {
            if (ModelState.IsValid)
            {
                _context.Add(skill);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(skill));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("ID,Name,StartDate")] Project project)
        {
            if (ModelState.IsValid)
            {
                _context.Add(project);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(project));
        }
        public async Task <IActionResult> Create([Bind("FirstName,LastName,BirthDate,Phone,Adress,ZipCode")] Consultant consultant)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(consultant);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }
            return(View(consultant));
        }