Example #1
0
 public void UpdateChosenLocation()
 {
     if (location == null)
     {
         if (DisplayMessageBoxes)
         {
             MessageBox.Show("Choose element to update", "Error message");
         }
         else
         {
             throw new NullReferenceException();
         }
     }
     else if (Name == null || Name == "" || CostRate < 0 || Availability < 0)
     {
         if (DisplayMessageBoxes)
         {
             MessageBox.Show("You provided incorrect value", "Error message");
         }
         else
         {
             throw new FormatException();
         }
     }
     else
     {
         runAsynchronously(() =>
         {
             model.UpdateLocation(location.LocationID, Name, CostRate, Availability, DateTime.Now);
             GetAllLocations.Execute(null);
         });
     }
 }
Example #2
0
 public void RemoveChosenLocation()
 {
     if (location == null)
     {
         if (DisplayMessageBoxes)
         {
             MessageBox.Show("Choose element to remove", "Error message");
         }
         else
         {
             throw new NullReferenceException();
         }
     }
     else
     {
         runAsynchronously(() =>
         {
             model.DeleteLocation(location.LocationID);
             GetAllLocations.Execute(null);
         });
     }
 }
Example #3
0
 public void AddNewLocation()
 {
     if (Name == null || Name == "" || CostRate < 0 || Availability < 0)
     {
         if (DisplayMessageBoxes)
         {
             MessageBox.Show("You provided incorrect value", "Error message");
         }
         else
         {
             throw new FormatException();
         }
     }
     else
     {
         runAsynchronously(() =>
         {
             model.AddLocation(0, Name, CostRate, Availability, DateTime.Now);
             GetAllLocations.Execute(null);
         });
     }
 }