public ActionResult TaskSubmit(FormCollection formCollection)
        {
            // Create a new task
            if (formCollection["newTask"] != null && formCollection["newTask"].Length != 0)
            {
                TasksDbHelper.AddTask(formCollection["newTask"],
                                      ClaimsPrincipal.Current.FindFirst(Globals.ObjectIdClaimType).Value,
                                      ClaimsPrincipal.Current.FindFirst(Globals.GivennameClaimType).Value + ' '
                                      + ClaimsPrincipal.Current.FindFirst(Globals.SurnameClaimType).Value);
            }

            // Change status of existing task
            if (formCollection["updateTasks"] != null)
            {
                foreach (string key in formCollection.Keys)
                {
                    if (key.StartsWith("task-id:"))
                    {
                        TasksDbHelper.UpdateTask(Convert.ToInt32(key.Substring(key.IndexOf(':') + 1)), formCollection[key]);
                    }
                }
            }

            // Delete a Task
            if (formCollection["delete"] != null && formCollection["delete"].Length > 0)
            {
                TasksDbHelper.DeleteTask(Convert.ToInt32(formCollection["delete"]));
            }

            return(RedirectToAction("Index", "Tasks"));
        }
        public ActionResult TaskSubmit(FormCollection formCollection)
        {
            if (User.IsInRole("Admin") || User.IsInRole("Writer"))
            {
                // Add A New task to Tasks.xml
                if (formCollection["newTask"] != null && formCollection["newTask"].Length != 0)
                {
                    TasksDbHelper.AddTask(formCollection["newTask"]);
                }
            }

            if (User.IsInRole("Admin") || User.IsInRole("Approver"))
            {
                // Change status of existing task
                foreach (string key in formCollection.Keys)
                {
                    if (key != "newtask" && key != "delete")
                    {
                        TasksDbHelper.UpdateTask(Convert.ToInt32(key), formCollection[key]);
                    }
                }
            }

            if (User.IsInRole("Admin"))
            {
                // Delete a Task
                foreach (string key in formCollection.Keys)
                {
                    if (key == "delete" && formCollection[key] != null && formCollection[key].Length > 0)
                    {
                        string[] toDelete = formCollection[key].Split(',');
                        foreach (string id in toDelete)
                        {
                            TasksDbHelper.DeleteTask(Convert.ToInt32(id));
                        }
                    }
                }
            }
            return(RedirectToAction("Index", "Tasks"));
        }
 public Models.Task Update(int id, Models.Task task)
 {
     // Update an existing task
     EnsureAccessToTask(id);
     return(TasksDbHelper.UpdateTask(id, task.Status));
 }
Exemple #4
0
 public Models.Task Update(int id, Models.Task task)
 {
     return(TasksDbHelper.UpdateTask(id, task.Status));
 }