示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Description,IsDone")] ToDoItem toDoItem)
        {
            if (id != toDoItem.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(toDoItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ToDoItemExists(toDoItem.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(toDoItem));
        }
        public IActionResult Edit(Tarefa tarefa)
        {
            // verificando se o model está válido
            if (!ModelState.IsValid)
            {
                return(View(tarefa));
            }

            //atualizando o registro
            _context.Update(tarefa);
            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Edit(int id, Item items)
        {
            if (id != items.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(items);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemsExists(items.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(items));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Description,DueDate,Complete,IdNetUsers")] TodoItem todoItem)
        {
            if (id != todoItem.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(todoItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TodoItemExists(todoItem.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdNetUsers"] = new SelectList(_context.TodoItem, "Id", "Description", todoItem.IdNetUsers);
            return(View(todoItem));
        }
示例#5
0
        public void Update(Guid id)
        {
            var data = _dbSet.Find(id);

            data.Checado = !data.Checado;
            _context.Update(data);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description,Status")] ToDoList.Models.SomeTask SomeTask)
        {
            if (ModelState.IsValid)
            {
                _context.Update(SomeTask);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(SomeTask));
        }
示例#7
0
        public async Task <ActionResult> Edit(TodoList item)
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            if (ModelState.IsValid)
            {
                item.UserId = userId;
                context.Update(item);
                await context.SaveChangesAsync();

                TempData["Success"] = "The item has been updated!";

                return(RedirectToAction("Index"));
            }
            return(View(item));
        }
示例#8
0
        public async Task <Person> UpdatePerson(string pesel, Person person)
        {
            if (pesel != person.Pesel)
            {
                throw new ArgumentNullException("Given pesel does not exist.");
            }
            Person per = await _dbContext.Persons.AsNoTracking().SingleOrDefaultAsync(p => p.Pesel == pesel);

            if (per == null)
            {
                throw new ArgumentNullException("There's no person with such pesel");
            }
            _dbContext.Update(person);
            await _dbContext.SaveChangesAsync();

            return(person);
        }
 public void UpdateToDoItem(ToDoItem toDoItem)
 {
     _context.Update(toDoItem);
 }