Esempio n. 1
0
        public ActionResult Register(Task t)
        {
            try
            {
                var           identity = HttpContext.User.Identity as ClaimsIdentity;
                IList <Claim> claim    = identity.Claims.ToList();

                var task = new Task {
                    Name     = t.Name,
                    Content  = t.Content,
                    AuthorID = Int32.Parse(claim[0].Value)
                };
                _taskDbContext.Task.Add(task);
                _taskDbContext.SaveChanges();
                return(Ok(new
                {
                    Status = 1,
                    Message = "Task registered",
                    Task = task
                }));
            }
            catch (Exception ex)
            {
                return(Ok(new
                {
                    Status = 0,
                    Message = "Failed to register task",
                    Detail = ex.Message
                }));
            }
        }
        public ActionResult Create([Bind(Include = "ID,Name")] Board board)
        {
            if (ModelState.IsValid)
            {
                db.Boards.Add(board);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(board));
        }
        public ActionResult Create([Bind(Include = "ID,Title,Description,CreatedDate,DueDate,Tag,CurrentStatus,BoardID")] Task task)
        {
            if (ModelState.IsValid)
            {
                db.Tasks.Add(task);
                db.SaveChanges();
                return(RedirectToAction("Details", "Boards", new { id = task.BoardID }));
            }

            return(View(task));
        }
        public ActionResult Create([Bind(Include = "id,name,description,dateCreated,dateUpdated")] task task)
        {
            if (ModelState.IsValid)
            {
                task.dateCreated = DateTime.Now;
                db.tasks.Add(task);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(task));
        }
        public object PostTask([Microsoft.AspNetCore.Mvc.FromBody] PostTaskRequest message)
        {
            var item = new Task1
            {
                Text        = message.Text,
                Date        = message.Date,
                IsCompleted = message.IsCompleted,
            };

            db.Tasks.Add(item);
            db.SaveChanges();
            return(item);
        }
Esempio n. 6
0
        public ActionResult Create(TaskItem taskitem)
        {
            if (ModelState.IsValid)
            {
                taskitem.Completed = false;
                taskitem.EntryDate = DateTime.Now;
                db.Tasks.Add(taskitem);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(taskitem));
        }
Esempio n. 7
0
        public IActionResult Add(TaskListModel task)
        {
            var newID = _context.TaskList.Select(x => x.ID).Max() + 1;

            task.ID          = newID;
            task.UpdatedDate = DateTime.Now;
            task.TaskUserId  = Convert.ToInt32(HttpContext.Session.GetString("UserLog"));


            _context.TaskList.Add(task);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                Task task = new Task
                {
                    Name        = collection["Name"],
                    IsCompleted = false,
                    Created     = DateTime.Now
                };

                Tdb.Tasks.Add(task);
                Tdb.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                return(PartialView("_NewTask"));
            }
        }
Esempio n. 9
0
        public ActionResult Create(Task task, bool sendEmail)
        {
            if (ModelState.IsValid)
            {
                if (sendEmail)
                {
                    Utilities.SendEmail(task.Who, task.TaskName, task.TaskDescription);
                }

                task.Priority = Convert.ToInt32(Request.Form["rating"]);

                task.Date = DateTime.Now;

                db.Tasks.Add(task);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(task));
        }
Esempio n. 10
0
        private static void TaskDataInitializer(IServiceProvider serviceProvider)
        {
            using (var context = new TaskDBContext(
                       serviceProvider.GetRequiredService <DbContextOptions <TaskDBContext> >()))
            {
                if (context.TaskList.Any())
                {
                    return;
                }

                context.TaskList.AddRange(
                    new TaskListModel
                {
                    ID = 101,
                    TaskDescription = "Created - Task Cloud Migration",
                    TaskHead        = "Cloud Migration",
                    TaskUserId      = 101,
                    UpdatedDate     = DateTime.Now,
                    TaskChecked     = false
                }, new TaskListModel
                {
                    ID = 102,
                    TaskDescription = "Created - Task SAAS Migration",
                    TaskHead        = "SAAS Migration",
                    TaskUserId      = 102,
                    UpdatedDate     = DateTime.Now,
                    TaskChecked     = false
                }
                    );

                if (context.LogModel.Any())
                {
                    return;
                }

                context.LogModel.AddRange(
                    new LogModel
                {
                    ID       = 101,
                    UserName = "******",
                    Password = "******"
                }, new LogModel
                {
                    ID       = 102,
                    UserName = "******",
                    Password = "******"
                }
                    );


                context.SaveChanges();
            }
        }
Esempio n. 11
0
 public ActionResult Create(Job job)
 {
     if (ModelState.IsValid)
     {
         using (var db = new TaskDBContext())
         {
             db.Job.Add(job);
             db.SaveChanges();
         }
     }
     return(RedirectToAction($"GetById/{job.Id}"));
 }
Esempio n. 12
0
 public ActionResult New(Task1 task)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Tasks.Add(task);
             db.SaveChanges();
             TempData["message"] = "Task added!";
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View(task));
         }
     }
     catch (Exception e)
     {
         return(View(task));
     }
 }
Esempio n. 13
0
        public ActionResult Edit(Job job)
        {
            int id = job.Id;

            using (var db = new TaskDBContext())
            {
                if (ModelState.IsValid)
                {
                    db.Entry(job).State = EntityState.Modified;
                    db.SaveChanges();
                }
                return(RedirectToAction($"getbyid/{job.Id}"));
            }
        }
Esempio n. 14
0
 public ActionResult Delete(int id)
 {
     using (var db = new TaskDBContext())
     {
         Job job = db.Job.Find(id);
         foreach (var i in db.Job
                  .Where(x => x.ParentId == id))
         {
             i.ParentId = null;
         }
         db.Job.Remove(job);
         db.SaveChanges();
         return(RedirectToAction("GetAll"));
     }
 }
Esempio n. 15
0
 public ActionResult Register(Author a)
 {
     try
     {
         _taskDbContext.Author.Add(a);
         _taskDbContext.SaveChanges();
         return(Ok(new
         {
             Status = 1,
             Message = "Author registered",
             Author = a
         }));
     }
     catch (Exception ex)
     {
         return(Ok(new
         {
             Status = 0,
             Message = "Failed to register Author",
             Detail = ex.Message
         }));
     }
 }
Esempio n. 16
0
 public void AddSubTasks(SubTask tasks)
 {
     db.SubTasks.Add(tasks);
     db.SaveChanges();
 }
Esempio n. 17
0
 public void AddUser(Users users)
 {
     db.Users.Add(users);
     db.SaveChanges();
 }
Esempio n. 18
0
 public void AddNewTask(Task task)
 {
     _db.Tasks.Add(task);
     _db.SaveChanges();
 }
Esempio n. 19
0
 public void AddTasks(Tasks tasks)
 {
     db.Tasks.Add(tasks);
     db.SaveChanges();
 }