Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,Id")] WorkItemState workItemState)
        {
            if (id != workItemState.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(workItemState);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WorkItemStateExists(workItemState.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(workItemState));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,CreatedAt,Id")] User user)
        {
            if (id != user.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    user.CreatedAt = _context.User.AsNoTracking().Where(w => w.Id == id).FirstOrDefault().CreatedAt; // AsNoTracking
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }