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 Models.Task Create(Models.Task task)
        {
            // Create a new task
            if (task.TaskText != null && task.TaskText.Length != 0)
            {
                return(TasksDbHelper.AddTask(task.TaskText,
                                             ClaimsPrincipal.Current.FindFirst(Globals.ObjectIdClaimType).Value,
                                             ClaimsPrincipal.Current.FindFirst(Globals.GivennameClaimType).Value + ' '
                                             + ClaimsPrincipal.Current.FindFirst(Globals.SurnameClaimType).Value));
            }

            throw new HttpResponseException(HttpStatusCode.BadRequest);
        }
        public ActionResult Create(string text)
        {
            // Create a new task
            if (text != null && text.Length != 0)
            {
                Models.Task task = TasksDbHelper.AddTask(text,
                                                         ClaimsPrincipal.Current.FindFirst(Globals.ObjectIdClaimType).Value,
                                                         ClaimsPrincipal.Current.FindFirst(Globals.GivennameClaimType).Value + ' '
                                                         + ClaimsPrincipal.Current.FindFirst(Globals.SurnameClaimType).Value);

                return(RedirectToAction("Index"));
            }

            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
        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"));
        }