Beispiel #1
0
 public virtual ActionResult New(int storyId)
 {
     Story story = _StoryService.GetStoryById(storyId);
     Task task = new Task()
     {
         Hours = 0,
         StoryId = storyId,
         TaskId = 0
     };
     return PartialView("Edit", task);
 }
Beispiel #2
0
 public static Task GetTaskById(ScrumTimeEntities scrumTimeEntities, int id)
 {
     Task task = null;
     var results = from t in scrumTimeEntities.Tasks
                   where t.TaskId == id
                   select t;
     if (results.Count() > 0)
         task = results.First<Task>();
     else
         task = new Task();
     return task;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Tasks EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTasks(Task task)
 {
     base.AddObject("Tasks", task);
 }
 /// <summary>
 /// Create a new Task object.
 /// </summary>
 /// <param name="taskId">Initial value of the TaskId property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 /// <param name="storyId">Initial value of the StoryId property.</param>
 public static Task CreateTask(global::System.Int32 taskId, global::System.String description, global::System.Int32 storyId)
 {
     Task task = new Task();
     task.TaskId = taskId;
     task.Description = description;
     task.StoryId = storyId;
     return task;
 }
Beispiel #5
0
        public virtual ActionResult Save(FormCollection collection)
        {
            try
            {
                string storyId = collection.Get("storyId");
                string id = collection.Get("taskId");
                bool newTask = false;
                if (id == null || id == "0")
                {
                    id = "0";
                    newTask = true;
                }
                string description = collection.Get("description");
                string hours = collection.Get("hours");
                // TODO:  Validate the story data before saving
                // TODO:  Set the correct product id
                Task task = new Task()
                {
                    TaskId = Int32.Parse(id),
                    StoryId = Int32.Parse(storyId),
                    Description = description,
                    Hours = decimal.Parse(hours),
                };
                _TaskService.SaveTask(task);

                if (newTask)
                    return RedirectToAction("ListById", new { storyId = storyId });
                else
                    return RedirectToAction("ReadOnly", new { id = Int32.Parse(id) });
            }
            catch
            {
                return View();  // TODO:  Handle displaying the exception condition
            }
        }
Beispiel #6
0
 protected ScrumDetail BuildScrumDetail(Sprint sprint, Task task)
 {
     Scrum mostRecentScrum = GetMostRecentScrum(sprint);
     ScrumDetail mostRecentScrumDetail = null;
     if (mostRecentScrum != null && mostRecentScrum.ScrumDetails.Count() > 0)
     {
         var results = from s in mostRecentScrum.ScrumDetails
                       where s.TaskId == task.TaskId
                       select s;
         if (results.Count() > 0)
             mostRecentScrumDetail = results.First();
     }
     ScrumDetail scrumDetail = new ScrumDetail()
     {
         AssignedTo = (mostRecentScrumDetail != null) ? mostRecentScrumDetail.AssignedTo : AccountMembershipService.UNASSIGNED,
         HoursCompleted = (mostRecentScrumDetail != null) ? mostRecentScrumDetail.HoursCompleted : 0,
         HoursRemaining = (mostRecentScrumDetail != null) ? mostRecentScrumDetail.HoursRemaining :
             ( (task.Hours != null) ? (int)task.Hours : 0 ),
         StoryTaskDescription = task.Story.UserDefinedId + " -> " + task.Description,
         TaskId = task.TaskId
     };
     return scrumDetail;
 }
Beispiel #7
0
        public Task SaveTask(Task task)
        {
            if (task != null)
            {
                if (task.TaskId == 0)  // this is new
                {
                    _ScrumTimeEntities.AddToTasks(task);
                }
                else  // the story exists
                {
                    _ScrumTimeEntities.AttachTo("Tasks", task);

                    ScrumTimeEntities freshScrumTimeEntities =
                        new ScrumTimeEntities(_ScrumTimeEntities.Connection.ConnectionString);
                    Task existingTask = GetTaskById(freshScrumTimeEntities, task.TaskId);
                    if (existingTask == null)
                    {
                        throw new Exception("The task no longer exists.");
                    }
                    _ScrumTimeEntities.ObjectStateManager.ChangeObjectState(task, System.Data.EntityState.Modified);
                }
                _ScrumTimeEntities.SaveChanges();
            }
            return task;
        }