Exemplo n.º 1
0
        public IActionResult Index(string NewItem)
        {
            var currentToDo = new TodoModel {
                TaskName = NewItem
            };

            _context.Add(currentToDo);
            _context.SaveChanges();

            return(View(_context.Todos.ToList()));
        }
Exemplo n.º 2
0
        // PUT api/Todo/5
        public HttpResponseMessage PutTodoItem(int id, TodoItem todoitem)
        {
            if (ModelState.IsValid && id == todoitem.TodoItemId)
            {
                db.Entry(todoitem).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Exemplo n.º 3
0
 public IActionResult Create(Item item)
 {
     db.Items.Add(item);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 4
0
 public IActionResult Create(Category category)
 {
     db.Categories.Add(category);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }