Exemplo n.º 1
0
        public async Task EnsureSeedData()
        {
            _context.Database.EnsureCreated();

            _context.Tasks.RemoveRange(_context.Tasks);
            _context.SaveChanges();

            var task = new TaskEntity
            {
                Title       = "Read a book",
                TaskDetails = "Read Sadguru books"
            };

            _context.Add(task);

            var task2 = new TaskEntity
            {
                Title       = "Go to temple",
                TaskDetails = "Go to temple"
            };

            _context.Add(task2);

            await _context.SaveChangesAsync();
        }
Exemplo n.º 2
0
 public async Task <IActionResult> Create(Task task)
 {
     if (ModelState.IsValid)
     {
         task.Id = 0;
         task.DateOfRegistration = DateTime.Now;
         task.TaskStatus         = TaskStatus.Appointed;
         _context.Add(task);
         await _context.SaveChangesAsync();
     }
     return(RedirectToAction("Index", new { selectedTaskId = task.Id }));
 }