コード例 #1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,Description,Changes,DateStart,DateEnd")] TableForEmployee tableForEmployee)
        {
            if (id != tableForEmployee.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tableForEmployee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TableForEmployeeExists(tableForEmployee.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tableForEmployee));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,Description,Changes,DateStart,DateEnd")] TableForEmployee tableForEmployee)
        {
            if (ModelState.IsValid)
            {
                tableForEmployee.Id = Guid.NewGuid();
                _context.Add(tableForEmployee);
                await _context.SaveChangesAsync();

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