/// <summary> /// Creates the new backlog item and saves it. /// </summary> private void CreateNewBacklogItem(BacklogItem newItem) { // save its executor.StartBackgroundTask( () => { backlogService.AddBacklogItem(newItem); }, () => { NewItemName = String.Empty; BacklogItemViewModel vm = new BacklogItemViewModel(); vm.Init(backlogService, executor, aggregator, authorizator, Project, newItem); // TO THIS STRANGE CHECK 'CUZ WHEN LIST IS EMPTY COMMITNEW THROWS STRANGE EXCEPTION if (FilteredBacklog.IsEmpty || Items.Count == 0) { Items.Add(vm); backlogViewSource.View.Refresh(); } else { ((System.Windows.Data.ListCollectionView)backlogViewSource.View).AddNewItem(vm); ((System.Windows.Data.ListCollectionView)backlogViewSource.View).CommitNew(); } vm.NotifyAdded(); aggregator.Publish<BacklogItem[]>(ScrumFactoryEvent.BacklogItemsChanged, new BacklogItem[] { newItem }); }); }
private void AddJob() { if (String.IsNullOrEmpty(NewTicketName)) return; if (NewTicketProject == null) return; // create the new item BacklogItem newItem = new BacklogItem { BacklogItemUId = Guid.NewGuid().ToString(), ProjectUId = NewTicketProject.ProjectUId, Name = NewTicketName, Description = null, Status = (short)BacklogItemStatus.ITEM_REQUIRED, BusinessPriority = 0, OccurrenceConstraint = 1, SizeFactor = 1, CreateDate = DateTime.Now }; // save its executor.StartBackgroundTask( () => { // needs to get the project here to get its roles Project project = projectsService.GetProject(newItem.ProjectUId); newItem.Project = project; newItem.SyncPlannedHoursAndRoles(1); ICollection<BacklogItemGroup> groups = backlogService.GetBacklogItemGroups(project.ProjectUId); BacklogItemGroup group = groups.FirstOrDefault(g => g.DefaultGroup == (short)DefaultItemGroups.DEV_GROUP); if (group != null) newItem.GroupUId = group.GroupUId; backlogService.AddBacklogItem(newItem); }, () => { BacklogItemViewModel vm = new BacklogItemViewModel(); vm.Init(backlogService, executor, aggregator, authorizator, newTicketProject, newItem); ICollection<BacklogItemViewModel> tickets = ticketsSource.Source as ICollection<BacklogItemViewModel>; tickets.Add(vm); ((IEditableCollectionView)ticketsSource.View).EditItem(vm); ((IEditableCollectionView)ticketsSource.View).CommitEdit(); vm.NotifyAdded(); NewTicketProject = null; NewTicketName = String.Empty; }); }