public static TestCaseProxy TestCaseModelToProxy(TestCase model)
        {
            TestCaseProxy proxyObject = new TestCaseProxy();
            proxyObject.Id = model.ID;
            proxyObject.Title = model.Title;
            proxyObject.Priority = EnumUtil.ParseEnum<Priority>(model.Priority);
            proxyObject.Severity = EnumUtil.ParseEnum<Severity>(model.Severity);
            proxyObject.IsAutomated = model.IsAutomated;
            proxyObject.CreatedBy = model.CreatedBy;
            proxyObject.UpdatedBy = model.UpdatedBy;
            proxyObject.AreaID = model.AreaID;

            foreach (var item in new TestManager().GetStepDefinitionsById(model.ID))
            {
                StepDefinitionProxy proxy = new StepDefinitionProxy();
                proxy.Step = item.Step;
                proxy.ExpectedResult = item.ExpectedResult;
                proxy.ID = item.ID;
                proxy.TestCaseID = item.TestCaseID;

                proxyObject.StepDefinitionList.Add(proxy);
            }

            return proxyObject;
        }
        public static TestCaseProxy Prompt(TestCaseProxy editTestCase)
        {
            TestCaseDialog inst = new TestCaseDialog(editTestCase);
            inst.ShowDialog();

            return testCase;
        }
        public static TestCase TestCaseProxyToModel(TestCaseProxy proxy)
        {
            TestCase testCase = new TestCase();
            testCase.ID = proxy.Id;
            testCase.Title = proxy.Title;
            testCase.Priority = proxy.Priority.ToString();
            testCase.Severity = proxy.Severity.ToString();
            testCase.IsAutomated = proxy.IsAutomated;
            testCase.CreatedBy = proxy.CreatedBy;
            testCase.UpdatedBy = proxy.UpdatedBy;
            testCase.AreaID = proxy.AreaID;
            testCase.StepDefinitions = StepDefinitionModelToProxy(proxy.StepDefinitionList);

            return testCase;
        }
        public TestCaseDialog(TestCaseProxy editTestCase)
            : this()
        {
            this.CreateOrEditTestCase.Content = "Save Test Case";

            this.TestCaseTitleValidation(editTestCase.Title);
            this.testCaseId = editTestCase.Id;
            this.PriorityComboBox.SelectedIndex = (int)editTestCase.Priority;
            this.SeverityComboBox.SelectedIndex = (int)editTestCase.Severity;
            this.IsAutomatedCheckBox.IsChecked = editTestCase.IsAutomated;

            // Deep clone is needed in case of step definitions changes, which are not saved in the db.
            this.stepDefinitionList = DeepCloneUtility.DeepClone(editTestCase.StepDefinitionList);
            this.TestStepList.ItemsSource = this.stepDefinitionList;

            this.isEditingExistingTestCase = true;
        }
        private void CreateTestCase(object sender, RoutedEventArgs e)
        {
            this.TestCaseTitleValidation(this.TestCaseTitle.Text);

            if (!string.IsNullOrWhiteSpace(this.TestCaseTitle.Text))
            {
                TestCaseProxy testCase = new TestCaseProxy();
                testCase.Id = this.testCaseId;
                testCase.Title = this.TestCaseTitle.Text;
                testCase.Priority = EnumUtil.ParseEnum<Priority>((this.PriorityComboBox.SelectedItem as ComboBoxItem).Content.ToString());
                testCase.Severity = EnumUtil.ParseEnum<Severity>((this.SeverityComboBox.SelectedItem as ComboBoxItem).Content.ToString());
                testCase.IsAutomated = this.IsAutomatedCheckBox.IsChecked ?? false;

                testCase.StepDefinitionList = new ObservableCollection<StepDefinitionProxy>();
                foreach (var item in this.TestStepList.ItemsSource)
                {
                    StepDefinitionProxy stepDefinition = new StepDefinitionProxy();
                    stepDefinition.ID = (item as StepDefinitionProxy).ID;
                    stepDefinition.Step = (item as StepDefinitionProxy).Step;
                    stepDefinition.ExpectedResult = (item as StepDefinitionProxy).ExpectedResult;
                    stepDefinition.TestCaseID = testCase.Id;

                    testCase.StepDefinitionList.Add(stepDefinition);
                }

                TestManager manager = new TestManager();

                if (!this.isEditingExistingTestCase)
                {
                    TestCaseDialog.testCase = ProxyConverter.TestCaseModelToProxy(manager.Create(relatedArea.ID, ModelConverter.TestCaseProxyToModel(testCase)));
                }
                else
                {
                    TestCaseDialog.testCase = ProxyConverter.TestCaseModelToProxy(manager.Update(ModelConverter.TestCaseProxyToModel(testCase)));
                }

                this.CancelDialog();
            }
        }
        private void EditTestCaseFromProxy(TestCaseProxy testCase)
        {
            TestCaseProxy editedTestCase = TestCaseDialog.Prompt(testCase);

            if (editedTestCase != null)
            {
                ProjectProxy projectProxy = this.UIProjectProxyList.Where(proj => proj.Areas.Any(a => a.ID == testCase.AreaID)).FirstOrDefault();
                if (UIProjectProxyList != null)
                {
                    AreaProxy areaProxy = projectProxy.Areas.Where(a => a.ID == testCase.AreaID).FirstOrDefault();
                    if (areaProxy != null)
                    {
                        areaProxy.TestCasesList.Remove(testCase);
                        areaProxy.TestCasesList.Add(editedTestCase);

                        this.SetCurrentTestCase(editedTestCase);
                    }
                }
            }
        }