Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MariaDBDialogViewModel : ValidatableBindableBase, IRegionManagerAware
- {
- public MariaDBDialogViewModel()
- {
- SaveCommand = new DelegateCommand(OnSaveExecute, CanExecuteSave);
- }
- #region Methods
- //TODO:
- private bool CanExecuteSave()
- {
- return true;
- }
- /// <summary>
- /// Save Data for Maria DB
- /// </summary>
- private void OnSaveExecute()
- {
- try
- {
- ClearAllErrors();
- _mariaDBModel = new MariaDBModel
- {
- DBType = "MariaDB",
- DSName = DSName,
- Description = Description,
- IPAddress = IPAddress,
- Username = Username,
- Password = Password
- };
- var validator = new MariaDBValidator();
- ValidationResult result = validator.Validate(_mariaDBModel);
- foreach (var error in result.Errors)
- {
- SetError(error.PropertyName, error.ErrorMessage);
- }
- if (!result.IsValid)
- return;
- _dataController.AddNewDataSet(_mariaDBModel.DSName, _mariaDBModel);
- }
- finally
- {
- Logging.For<MariaDBDialog>().Trace("DataSet was saved successfully.");
- }
- }
- #endregion
- #region Properties
- private MariaDBModel _mariaDBModel;
- public DelegateCommand SaveCommand { get; private set; }
- IDataController _dataController = new DataController();
- private string _dsName;
- public string DSName
- {
- get { return _dsName; }
- set { SetProperty(ref _dsName, value); }
- }
- private string _description;
- public string Description
- {
- get { return _description; }
- set { SetProperty(ref _description, value); }
- }
- private string _dbType;
- public string DBType
- {
- get { return _dbType; }
- set { SetProperty(ref _dbType, value); }
- }
- private string _ipAddress;
- public string IPAddress
- {
- get { return _ipAddress; }
- set { SetProperty(ref _ipAddress, value); }
- }
- private string _username;
- public string Username
- {
- get { return _username; }
- set { SetProperty(ref _username, value); }
- }
- // Unsafe storage
- private string _password;
- public string Password
- {
- get { return _password; }
- set { SetProperty(ref _password, value); }
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement