public async Task <IActionResult> Edit(int id, [Bind("WorkerID,FirstName,LastName,Age,City,Email,JoinedDate")] Worker worker)
        {
            if (id != worker.WorkerID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(worker);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WorkerExists(worker.WorkerID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(worker));
        }
Exemple #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ContractID,ContractName,ExpiryDate,Reward")] Contract contract)
        {
            if (id != contract.ContractID)
            {
                return(NotFound());
            }

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