Esempio n. 1
0
        public ActionResult DeleteTask(string TaskID)
        {
            Capstone6Entities orm = new Capstone6Entities();
            Task Found            = orm.Tasks.Find(TaskID);

            orm.Tasks.Remove(Found);
            orm.SaveChanges();
            return(RedirectToAction("TaskList"));
        }
Esempio n. 2
0
        public ActionResult SaveNewTask(Task newTask)
        {
            Capstone6Entities orm = new Capstone6Entities();

            orm.Tasks.Add(newTask);

            orm.SaveChanges();

            return(RedirectToAction("TaskList"));
        }
Esempio n. 3
0
        public ActionResult RegisterNewUser(User newUser)
        {
            Capstone6Entities ORM = new Capstone6Entities();

            ORM.Users.Add(newUser);

            ORM.SaveChanges();

            return(View("Index"));
        }
Esempio n. 4
0
        public ActionResult UserTaskDelete(Task deleteItem)
        {
            //1. create ORM
            Capstone6Entities ORMtask = new Capstone6Entities();

            //2. get old item
            Task getItem = ORMtask.Tasks.Find(deleteItem.taskID); // use edit item name to find old item

            //4. push to DB

            ORMtask.Entry(getItem).State = System.Data.Entity.EntityState.Deleted;
            ORMtask.SaveChanges();

            //5. return to the list of item
            return(RedirectToAction("UserTasksView")); // action to action instead of action to view
        }
Esempio n. 5
0
        public ActionResult UserTaskComplete(int whichTasks, int currentUser)
        {
            int numberToReturn = currentUser;
            //1. create ORM
            Capstone6Entities ORMtask = new Capstone6Entities();

            //2. find item
            Task getItem = ORMtask.Tasks.Find(whichTasks); // use edit item name to find old item

            //3. change item
            getItem.isComplete = true;
            //4. push to DB
            ORMtask.Entry(getItem).State = System.Data.Entity.EntityState.Modified;
            ORMtask.SaveChanges();

            //5. return to the list of item
            return(RedirectToAction("UserTasksView", new { currentUser = numberToReturn })); // action to action instead of action to view
        }
Esempio n. 6
0
        public ActionResult ChangeStatus(string TaskID)
        {
            Capstone6Entities ORM = new Capstone6Entities();
            Task Found            = ORM.Tasks.Find(TaskID);

            if (Found.Status == "incomplete")
            {
                Found.Status = "complete";
            }
            else
            {
                Found.Status = "incomplete";
            }


            ORM.Entry(Found).State = System.Data.Entity.EntityState.Modified;

            ORM.SaveChanges();
            return(RedirectToAction("TaskList"));
        }
Esempio n. 7
0
        public ActionResult AddNew(Task newTask)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Capstone6Entities ORMtask = new Capstone6Entities();

                    var searchDup = ORMtask.Tasks.Where(x => x.taskID == newTask.taskID).SingleOrDefault();

                    if (searchDup == null)
                    {
                        ORMtask.Entry(newTask).State = System.Data.Entity.EntityState.Added;
                        ORMtask.SaveChanges();

                        ViewBag.AllItems = ORMtask.Tasks.ToList <Task>();
                        return(RedirectToAction("UserTasksView"));
                    }
                    else
                    {
                        ViewBag.WhereError = "Task ID Already in database";
                        return(View("Error"));
                    }
                }
                else
                {
                    ViewBag.WhereError = "Model State Not Vaild";
                    return(View("Error"));
                }
            }
            catch (Exception)
            {
                ViewBag.WhereError = "Exception Error in Add Item";
                return(View("Error"));
            }
        }