Exemplo n.º 1
0
        public IActionResult Edit(int id, [Bind("Id,Name,ContactPhoneNumber")] Employee employee)
        {
            if (id != employee.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employee);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
        public IActionResult Edit(int id, [Bind("Id,EmployeeId,DepartmentId,StartTime,EndTime,Date")] TimeRecord timeRecord)
        {
            if (id != timeRecord.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(timeRecord);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TimeRecordExists(timeRecord.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "Id", "Id", timeRecord.DepartmentId);
            ViewData["EmployeeId"]   = new SelectList(_context.Employee, "Id", "Id", timeRecord.EmployeeId);
            return(View(timeRecord));
        }