コード例 #1
0
        private async Task GetSuppliers()
        {
            try
            {
                IsProgressing = true;
                Suppliers     = new ObservableCollection <SupplierModel>();
                var projectSuppliers = await projectSuppliersAPIHelper.GetProjectSuppliersByProjectID(ParentLayout.LoggedInUser.Token, ParentLayout.SelectedProject.ID);

                projectSuppliers.ToList().ForEach(ps => Suppliers.Add(ps.Supplier));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
            finally
            {
                IsProgressing = false;
            }
        }
コード例 #2
0
        private async void OpenCloseOperations(object value)
        {
            try
            {
                switch (value.ToString())
                {
                case "Edit":
                    if (SelectedProject != null)
                    {
                        await GetContractors();
                        await GetSuppliers();

                        ColSpan = 1;
                        OperationsVisibility = "Visible";

                        ID             = SelectedProject.ID;
                        Title          = SelectedProject.Title;
                        Description    = SelectedProject.Description;
                        StartDate      = SelectedProject.StartDate;
                        DueDate        = SelectedProject.DueDate;
                        Address        = SelectedProject.Address;
                        Title          = SelectedProject.Title;
                        SelectedType   = SelectedProject.Type;
                        SelectedStatus = SelectedProject.Status;
                        SelectedFirm   = SelectedProject.Firm;
                        SelectedTeam   = SelectedProject.Team;

                        var projectContractors = await projectContractorsAPIHelper.GetProjectContractorsByProjectID(ParentLayout.LoggedInUser.Token, ID);

                        var projectSuppliers = await projectSuppliersAPIHelper.GetProjectSuppliersByProjectID(ParentLayout.LoggedInUser.Token, ID);

                        foreach (var pc in projectContractors)
                        {
                            pc.Contractor.IsChecked = true;
                            Contractors.FirstOrDefault(c => c.ID == pc.Contractor.ID).IsChecked = true;
                        }


                        foreach (var ps in projectSuppliers)
                        {
                            ps.Supplier.IsChecked = true;
                            Suppliers.FirstOrDefault(s => s.ID == ps.Supplier.ID).IsChecked = true;
                        }

                        SetContractorsCheckedText(null);
                        SetSuppliersCheckedText(null);


                        IsUpdate = true;
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Please select a record to edit", "Select Record", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }

                case "Create":
                    ID                   = 0;
                    IsUpdate             = false;
                    ColSpan              = 1;
                    OperationsVisibility = "Visible";
                    ClearFields();
                    await GetSuppliers();
                    await GetContractors();

                    break;

                default:
                    ColSpan = ColSpan == 1 ? 2 : 1;
                    OperationsVisibility = OperationsVisibility == "Visible" ? "Collapsed" : "Visible";
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }