Example #1
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description,DeadLineDate,Preority,Status,CategoryId")] TodoItem todoItem)
        {
            if (ModelState.IsValid)
            {
                todoItem.CreationDate = DateTime.UtcNow;
                _context.Add(todoItem);
                await _context.SaveChangesAsync();

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