private void InternalValidate() { ValidationMessages.Clear(); ExecuteValidation(); Error = string.Join(Environment.NewLine, ValidationMessages.Select(m => m.Value)); ValidationOk = ValidationMessages.Count == 0; }
public virtual bool CanBuySnack(int position) { ValidationMessages.Clear(); var snackPile = GetSnackPile(position); if (snackPile.Quantity == 0) { ValidationMessages.Add(Constants.NoSnackAvailableToBuy); return(false); } if (snackPile.Price > MoneyInTransaction) { ValidationMessages.Add(Constants.NotEnoughMoneyInserted); return(false); } if (!MoneyInside.CanAllocate(snackPile.Price)) { ValidationMessages.Add(Constants.NotEnoughChange); return(false); } return(true); }
public void CheckJobStatus() { var client = BrightstarService.GetClient(Store.Source.ConnectionString); _transactionJob = client.GetJobInfo(Store.Location, _transactionJob.JobId); if (_transactionJob.JobCompletedOk) { ValidationMessages.Clear(); ValidationMessages.Add(Strings.TransactionSuccess); } else if (_transactionJob.JobCompletedWithErrors) { ValidationMessages.Clear(); ValidationMessages.Add(Strings.TransactionFailed); ValidationMessages.Add(_transactionJob.ExtractJobErrorMessage(true)); Messenger.Default.Send( new ShowDialogMessage("Transaction failed", "Transaction failed with status: " + _transactionJob.StatusMessage, MessageBoxImage.Error, MessageBoxButton.OK), "MainWindow"); } else { _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new JobMonitorDelegate(this.CheckJobStatus)); } }
public async Task <bool> Save() { ValidationMessages.Clear(); var saveTasks = new List <Task>(); foreach (var recipient in Recipients.Where(x => x.IsChanged || x.IsNew)) { saveTasks.Add(Mediator.Send(new UpsertRecipientCommand { Address = recipient.Address, Name = recipient.Name, Verified = recipient.Verified })); } foreach (var deleted in _toDeleteRecipients) { saveTasks.Add(Mediator.Send(new DeleteRecipientCommand { Name = deleted.Name })); } try { await Task.WhenAll(saveTasks); _toDeleteRecipients.Clear(); Recipients.ForEach(x => x.ResetState()); return(true); } catch (ValidationException ex) { ValidationMessages = ex.Errors.Select(x => x.ErrorMessage).ToList(); StateHasChanged(); await JSRuntime.InvokeVoidAsync("scrollIntoView", "settings-recipient-top"); return(false); } }
private void Validate() { ValidationMessages.Clear(); if (String.IsNullOrEmpty(_location)) { ValidationMessages.Add("Please enter a store name."); } else if (InvalidStoreNameChars.Any(x => _location.Contains(x))) { ValidationMessages.Add("The store name may not contain any of the following characters: " + String.Join("", InvalidStoreNameChars)); } IsValid = ValidationMessages.Count == 0; }
private void ClearForm() { var toRemovefolder = AvailableFolderNames.FirstOrDefault(x => string.Equals(x, SelectedFolder, StringComparison.OrdinalIgnoreCase)); if (toRemovefolder is object) { AvailableFolderNames.Remove(toRemovefolder); } ValidationMessages.Clear(); Recipients.ForEach(x => x.IsChecked = false); SelectedFolder = null; SelectedFolderCreationOption = FolderCreationOption.CreateNew; }
public virtual void Reset(CommandType type) { if (CommandObject != null) { CommandObject.CommandText = string.Empty; CommandObject.CommandType = type; CommandObject.Parameters.Clear(); } LastExceptionMessage = string.Empty; LastException = null; RowsAffected = 0; IdentityGenerated = null; SQL = string.Empty; ValidationMessages.Clear(); }
public bool Validate() { bool ret = false; Entity.IsLoggedIn = false; ValidationMessages.Clear(); if (string.IsNullOrEmpty(Entity.UserName)) { AddValidationMessage("UserName", "User name must be filled in"); } if (string.IsNullOrEmpty(Entity.Password)) { AddValidationMessage("Password", "Password must be filled in"); } ret = (ValidationMessages.Count == 0); return(ret); }
public void Execute(RoutedEventArgs eventArgs) { ValidationMessages.Clear(); var executeButton = eventArgs.Source as Button; if (executeButton != null) { _dispatcher = executeButton.Dispatcher; var client = BrightstarService.GetClient(Store.Source.ConnectionString); // Instead of blocking, start the job and a background thread to monitor it var expandedAddTriples = GetExpandedTriples(AddTriples); var expandedDeleteTriples = GetExpandedDeletePatterns(); _transactionJob = client.ExecuteTransaction(Store.Location, null, expandedDeleteTriples, expandedAddTriples, waitForCompletion: false); ValidationMessages.Add("Executing transaction. Please wait..."); _dispatcher.BeginInvoke(DispatcherPriority.Normal, new JobMonitorDelegate(this.CheckJobStatus)); } }
public override bool IsValid() { ValidationMessages.Clear(); if (String.IsNullOrEmpty(FirstName)) { ValidationMessages.Add("First Name should be provided."); } else { if (FirstName.Length < 2) { ValidationMessages.Add("First Name should be more then 1 characters."); } } if (String.IsNullOrEmpty(LastName)) { ValidationMessages.Add("Last Name should be provided."); } else { if (LastName.Length < 2) { ValidationMessages.Add("Last Name should be more then 1 characters"); } } if (!String.IsNullOrEmpty(MobileNumber) && (MobileNumber.Length != 10 || !Regex.IsMatch(MobileNumber, "[0-9]"))) { ValidationMessages.Add("Mobile number should be of 10 digits."); } var validMemberships = (from membership in Memberships let currentTime = DateTime.UtcNow where currentTime >= membership.MemberFrom && currentTime <= membership.MemberExpiry select membership).Count(); if (validMemberships > 1) { ValidationMessages.Add("Too many valid memberships found for the user."); } return(ValidationMessages.Count == 0); }
public bool Validate() { bool ret = false; CurrentUser.IsLoggedIn = false; ValidationMessages.Clear(); if (string.IsNullOrEmpty(CurrentUser.UserName)) { AddApplicationExceptionMessage("UserName", "User Name Must Be Filled In"); } if (string.IsNullOrEmpty(CurrentUser.Password)) { AddApplicationExceptionMessage("Password", "Password Must Be Filled In"); } ret = (ValidationMessages.Count == 0); return(ret); }
public bool IsValid() { var valid = true; ValidationMessages.Clear(); if (string.IsNullOrEmpty(Username)) { valid = false; ValidationMessages.Add("Please enter a username!"); } if (string.IsNullOrEmpty(Password)) { valid = false; ValidationMessages.Add("Please enter a password!"); } return(valid); }
public virtual bool CanWithdrawal(decimal amount) { ValidationMessages.Clear(); if (amount <= 0m) { ValidationMessages.Add(Constants.InvalidAmount); return(false); } if (amount > MoneyInside.Amount) { ValidationMessages.Add(Constants.NotEnoughChange); return(false); } if (!MoneyInside.CanAllocate(amount)) { ValidationMessages.Add(Constants.NotEnoughChange); return(false); } return(true); }
public override void ClearMessages() { ValidationMessages.Clear(); termValidator.ClearMessages(); }
public virtual void Init() { ValidationMessages.Clear(); IsValidationVisible = false; }