Esempio n. 1
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create(Language language)
        {
            if (ModelState.IsValid)
            {
                _context.Add(language);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(language));
        }
Esempio n. 2
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create(Department department)
        {
            if (ModelState.IsValid)
            {
                _context.Add(department);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
        public async Task <string> AddWorkerAsync(Worker worker)
        {
            await dbContext.AddAsync(worker);

            await dbContext.SaveChangesAsync();

            return(worker.Id);
        }
Esempio n. 4
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create(Worker worker)
        {
            var errors = ModelState.Values.SelectMany(v => v.Errors);

            if (ModelState.IsValid)
            {
                worker.Department = await _context.Departments.FindAsync(worker.Department.Id);

                worker.Language = await _context.Languages.FindAsync(worker.Language.Id);

                _context.Add(worker);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            AddTablesInViewBag();
            return(View(worker));
        }