Пример #1
0
        private void CreateButton_Click(object sender, RoutedEventArgs e)
        {
            CreateButton.IsEnabled = false;
            if (IsInformationProvided())
            {
                if (decimal.TryParse(EstimatedHoursBox.Text, out decimal estimatedHours))
                {
                    string priority = PriorityComboBox.Text;
                    _crmConnector.CreateTask(((ComboBoxPairs)ProjectComboBox.SelectedItem).Value, TaskNameBox.Text,
                                             ((ComboBoxPairs)ResponsibleComboBox.SelectedItem).Value, PriorityComboBox.Text,
                                             DueDatePicker.SelectedDate, estimatedHours, DescriptionBox.Text);

                    Close();
                }
                else
                {
                    CreateButton.IsEnabled = true;
                    EstimatedHoursBox.Text = "";
                    MessageBox.Show("Please enter a valid estimation of hours!");
                }
            }
            else
            {
                CreateButton.IsEnabled = true;
            }
        }
Пример #2
0
        private async void GetButton_Click(object sender, RoutedEventArgs e)
        {
            GetButton.IsEnabled = false;

            if (IsInformationProvided() && await IsTfsInformationProvided())
            {
                List <ProjectTask> tasks = await _crmConnector.GetTfsTasks(((ComboBoxPairs)ProjectComboBox.SelectedItem).Value, TaskIdsBox.Text);

                foreach (ProjectTask task in tasks)
                {
                    if (!await OwnerIsCurrentUser(task.OwnerId))
                    {
                        MessageBox.Show($"You're not the owner of a task with id: {task.TfsId}");
                        continue;
                    }

                    if (await TaskAlreadyExists(task.TfsId))
                    {
                        MessageBox.Show($"Task with id: {task.TfsId} already exists");
                        continue;
                    }

                    if (!OwnerExists(task.OwnerId))
                    {
                        MessageBox.Show($"The owner of task with id: {task.TfsId} does not exist in CRM");
                        continue;
                    }

                    _crmConnector.CreateTask(((ComboBoxPairs)ProjectComboBox.SelectedItem).Value, task.TaskName, task.OwnerId,
                                             task.Priority, task.DueDate, task.EstimatedHours, task.Description, task.TfsId);
                }

                Close();
            }
            else
            {
                GetButton.IsEnabled = true;
            }
        }