/// <summary> /// Creates a Study Tasks and loads all study tasks to be shown /// </summary> /// <returns>A view which shows all tasks</returns> public ActionResult Index() { var client = CreateTasksWCFService(); var userId = User.Identity.GetUserId(); if (userId != null) { var userTasks = StudyTaskCollection.FromDatabase(client, userId); return(View(userTasks)); } return(View()); }
/// <summary> /// This method is invoked when the client adds a task /// </summary> /// <param name="taskName">The name of the task</param> /// <param name="estimateString">String representation of the estimated for the new task</param> /// <returns>a string of the task id and task total length in seconds, separated by commas</returns> public string Add(string taskName, string estimateString) { int estimate; // Check the string for a valid task name if (int.TryParse(estimateString, out estimate)) { string userId = User.Identity.GetUserId(); var client = CreateTasksWCFService(); var databaseConnection = StudyTaskCollection.FromDatabase(client, userId); var task = new StudyTask(client, taskName, userId, TimeSpan.FromSeconds(estimate)); databaseConnection.Add(task); var totalLength = task.GetLength(); return(string.Join(",", task.Id, totalLength.ToStringInSeconds())); } return(0.ToString()); }