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); }); } }
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); }); } }
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); }); } }