Example #1
0
        public void GetCustomerInvoiceGroupNames(bool isUpdate)
        {
            var temp = new ObservableCollection <CustomerInvoiceGroup>();

            _dataService.GetCustomerInvoiceGroupByCustomerId(_project.CustomerID).Subscribe(
                i =>
            {
                foreach (var customerInvoiceGroup in i)
                {
                    temp.Add(customerInvoiceGroup);
                }

                CustomerInvoiceGroupComboBoxItems = temp;
                CustomerInvoiceGroupComboBoxItems.Add(new CustomerInvoiceGroup {
                    Label = "Add new..."
                });

                if (_project.CustomerInvoiceGroupID != 0 && !isUpdate)
                {
                    SelectedCustomerInvoiceGroupItem = temp.First(t => t.CustomerInvoiceGroupID == _project.CustomerInvoiceGroupID);
                }

                else if (isUpdate)
                {
                    SelectedCustomerInvoiceGroupItem = temp.Last(r => r.CustomerID != 0);
                }
            });
        }
Example #2
0
        private void ExecuteSaveProject(object obj)
        {
            var customer = _project.Customer;
            var cig      =
                CustomerInvoiceGroupComboBoxItems.First(
                    c => c.CustomerInvoiceGroupID == SelectedCustomerInvoiceGroupItem.CustomerInvoiceGroupID);

            _project.Customer = null;
            //_project.CustomerInvoiceGroup = null;

            _project.CustomerInvoiceGroupID = SelectedCustomerInvoiceGroupItem.CustomerInvoiceGroupID;

            _project.ChangeTracker.OriginalValues.Clear();

            _dataService.SaveProject(_project).Subscribe(
                project =>
            {
                if (_isNew)
                {
                    if (project == null)
                    {
                        MessageBox.Show("BUG, Can't save right now.. please try press F5 and try again");
                        InternalCommands.ProjectAddCompleted.Execute(null);
                    }
                    else
                    {
                        _project.ProjectID = project.ProjectID;
                        _project.Customer  = customer;

                        _project.CustomerInvoiceGroup = cig;
                        _project.AcceptChanges();
                        InternalCommands.ProjectAddCompleted.Execute(_project);
                    }
                }
                else
                {
                    _project.Customer = customer;

                    _project.CustomerInvoiceGroup = CustomerInvoiceGroupComboBoxItems.First(i => i.CustomerInvoiceGroupID == SelectedCustomerInvoiceGroupItem.CustomerInvoiceGroupID);
                    _project.AcceptChanges();
                    InternalCommands.ProjectEditCompleted.Execute(_project);
                }
            }
                );
        }