public IActionResult Index(string NewItem)
        {
            var currentToDo = new TodoModel {
                TaskName = NewItem
            };

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

            return(View(_context.Todos.ToList()));
        }
Beispiel #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));
            }
        }
Beispiel #3
0
 public IActionResult Create(Item item)
 {
     db.Items.Add(item);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Beispiel #4
0
 public IActionResult Create(Category category)
 {
     db.Categories.Add(category);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }