コード例 #1
0
 public FullJobPOCO(JobPOCO job)
 {
     Id             = job.Id;
     ComponentsUsed = new Dictionary <ComponentPOCO, int>();
     foreach (var component in job.ComponentsUsed)
     {
         ComponentsUsed.Add(IDatabaseController.DatabaseController.GetComponent(component.Key).Result, component.Value);
     }
     Description = job.Description;
     Complete    = job.Complete;
 }
コード例 #2
0
        public static async Task <FullJobPOCO> BuildFullJobDTO(JobPOCO job)
        {
            var result = new FullJobPOCO();

            result.Id             = job.Id;
            result.ComponentsUsed = new Dictionary <ComponentPOCO, int>();
            foreach (var component in job.ComponentsUsed)
            {
                result.ComponentsUsed.Add(await IDatabaseController.DatabaseController.GetComponent(component.Key), component.Value);
            }
            result.Description = job.Description;
            result.Complete    = job.Complete;
            return(result);
        }
コード例 #3
0
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (CustomerComboBox.SelectedItem != null)
            {
                var newJob = new JobPOCO
                {
                    Complete       = false,
                    ComponentsUsed = new Dictionary <long, int>(),
                    Description    = ""
                };
                await DatabaseProvider.Database.AddJob(newJob);

                var newCustomerOrder = new CustomerOrderPOCO
                {
                    LinkedJobId = newJob.Id,
                    CustomerId  = MainWindow.AllCustomers.Find(x => $"{x.Id}: {x.FullName}" == (string)CustomerComboBox.SelectedItem).Id,
                    OrderDate   = OrderDatePicker.SelectedDate.Value,
                    OrderType   = OrderTypeTextBox.Text,
                    OrderDetals = OrderDescriptionTextBox.Text,
                    Completed   = false
                };
                await DatabaseProvider.Database.AddCustomerOrder(newCustomerOrder);

                newJob.Description = $"Относится к заказу #{newCustomerOrder.Id}";
                await DatabaseProvider.Database.UpdateJob(newJob);

                MainWindow.AllJobs.Add(await FullJobPOCO.BuildFullJobDTO(newJob));
                MainWindow.AllOrders.Add(await CustomerOrderFullPOCO.BuildCustomerOrderFullDTO(newCustomerOrder));

                ((MainWindow)this.Owner).RefreshJobsDataGrid();
                ((MainWindow)this.Owner).JobsDataGrid_SelectionChanged(null, null);
                ((MainWindow)this.Owner).RefreshOrdersDataGrid();
                ((MainWindow)this.Owner).CustomerOrdersDatagrid_SelectionChanged(null, null);

                this.Close();
            }
        }
コード例 #4
0
 public async Task <bool> UpdateJob(JobPOCO job)
 {
     return(await Connection.UpdateAsync(job) == 1);
 }
コード例 #5
0
 public async Task <bool> AddJob(JobPOCO job)
 {
     return(await Connection.SaveAsync(job));
 }