public void SalespersonControllerTest_Update()
        {
            Task.Run(async() =>
            {
                var person  = await controller.GetAsync(4);
                var oldName = person.Name;
                var newName = "Grzegorz";

                person.Name = newName;
                await controller.UpdateAsync(person);
                person = await controller.GetAsync(person.Id);
                Assert.AreEqual(newName, person.Name);

                person.Name = oldName;
                await controller.UpdateAsync(person);
                person = await controller.GetAsync(person.Id);

                Assert.AreEqual(oldName, person.Name);
            }).GetAwaiter().GetResult();
        }
Example #2
0
 private async void UpdateAllPeople_Click(object sender, RoutedEventArgs e)
 {
     if (editedPeople.Count == 0)
     {
         MessageBox.Show("There are no edits to save.", "Save edits", MessageBoxButton.OK, MessageBoxImage.Hand);
     }
     else
     {
         MessageBoxResult result = MessageBox.Show($"There are {editedPeople.Count} changes waiting to be saved. Do you want to send the update now?",
                                                   "Save edits",
                                                   MessageBoxButton.YesNo,
                                                   MessageBoxImage.Question);
         if (result.Equals(MessageBoxResult.Yes))
         {
             foreach (Salesperson person in editedPeople)
             {
                 await controller.UpdateAsync(person);
             }
             clearForms();
             editedPeople = new ObservableCollection <Salesperson>();
         }
     }
 }