public async Task <IActionResult> Edit(int id, [Bind("Id,Status,Name,Contacts,EmployerId")] Workers workers)
        {
            if (id != workers.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(workers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WorkersExists(workers.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployerId"] = new SelectList(_context.Employers, "Id", "Contacts", workers.EmployerId);
            return(View(workers));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Status,Name,Contacts")] Employers employers)
        {
            if (id != employers.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployersExists(employers.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(employers));
        }