public AddConnection(ValidationBase v, bool isEdit) { vm = v as ConnectionSettingVM; IsEdit = isEdit; InitializeComponent(); Loaded += AddConnection_Loaded; }
public virtual async Task <IActionResult> GetControlNumbersForEO([FromBody] GetControlNumbersForEOModel model) { BulkControlNumbersForEO response = null; try { Guid userUUID = Guid.Parse(HttpContext.User.Claims.Where(w => w.Type == "UserUUID").Select(x => x.Value).FirstOrDefault()); var officerId = new ValidationBase().GetOfficerIdByUserUUID(userUUID, _configuration); if (officerId == 0) { return(BadRequest(new { error_occured = true, error_message = "Officer not found" })); } var officerDetails = _payment.GetOfficerInfo(officerId); response = _payment.GetControlNumbersForEO(officerDetails.Code, model.ProductCode, model.AvailableControlNumbers); // Check if the product requested has enough CNs left _ = _payment.HandleControlNumbersToBeRequested(model.ProductCode); } catch (Exception ex) { return(BadRequest(new { error_occured = true, error_message = ex.Message })); } return(Ok(response)); }
public CreatePlayerValidator(IRepository repo) { _repo = repo; ValidationSequence = new ValidationBase <PlayerEntity>[] { new PlayerNullIdValidation <PlayerEntity>() }; }
private void AddValidation(YTagBuilder tagBuilder) { //$$$ // add some default validations //if (!PropData.ReadOnly) { // if (PropData.PropInfo.PropertyType == typeof(DateTime) || PropData.PropInfo.PropertyType == typeof(DateTime?)) { // tagBuilder.Attributes["data-val-date"] = __ResStr("valDate", "Please enter a valid value for field '{0}'", PropData.GetCaption(Container)); // tagBuilder.MergeAttribute("data-val", "true"); // } else if (PropData.PropInfo.PropertyType == typeof(int) || PropData.PropInfo.PropertyType == typeof(int?) || // PropData.PropInfo.PropertyType == typeof(long) || PropData.PropInfo.PropertyType == typeof(long?)) { // tagBuilder.Attributes["data-val-number"] = __ResStr("valNumber", "Please enter a valid number for field '{0}'", PropData.GetCaption(Container)); // tagBuilder.MergeAttribute("data-val", "true"); // } //} // Build validation attribute List <object> objs = new List <object>(); foreach (YIClientValidation val in PropData.ClientValidationAttributes) { // TODO: GetCaption can fail for redirects (ModuleDefinition) so we can't call it when there are no validation attributes // GridAllowedRole and GridAllowedUser use a ResourceRedirectList with a property OUTSIDE of the model. This only works in grids (where it is used) // but breaks when used elsewhere (like here) so we only call GetCaption if there is a validation attribute (FOR NOW). // That whole resource redirect business needs to be fixed (old and ugly, and fragile). string caption = PropData.GetCaption(Container); ValidationBase valBase = val.AddValidation(Container, PropData, caption, tagBuilder); if (valBase != null) { string method = valBase.Method; if (string.IsNullOrWhiteSpace(method)) { throw new InternalError($"No method given ({nameof(ValidationBase)}.{nameof(ValidationBase.Method)})"); } if (string.IsNullOrWhiteSpace(valBase.Message)) { throw new InternalError($"No message given ({nameof(ValidationBase)}.{nameof(ValidationBase.Message)})"); } objs.Add(valBase); method = method.TrimEnd("Attribute"); // remove ending ..Attribute method = method.TrimEnd("Validation"); // remove ending ..Validation valBase.Method = method.ToLower(); if (string.IsNullOrWhiteSpace(method)) { throw new InternalError($"No method name found after removing Attribute and Validation suffixes"); } } } if (objs.Count > 0) { tagBuilder.Attributes.Add("data-v", Utility.JsonSerialize(objs)); } }
public async Task <Playlist> ObterRecomendacaoPlaylistPorCidade(string nomeCidade) { var cidade = new Cidade(nomeCidade); if (!cidade.IsValid()) { return(ValidationBase.TratarMensagemErro <Playlist>(cidade.MensagensErro)); } cidade = await new OpenWeatherMapsProvider().ObterTemperaturaPorNomeCidade(cidade); var playlist = await new SpotifyProvider().ObterRecomendacaoPlaylistPorCategoria(cidade); return(playlist); }
public ServiceBase( IRepositoryBase <TEntity> _repository, INotificationManager _notificationManager, IMapper _mapper, IFluentValidation <TEntity> _fluentValidation ) : base(_notificationManager) { repository = _repository; mapper = _mapper; fluentValidation = _fluentValidation; // configure Validation Base validationBase = new ValidationBase <TEntity>(); validationBase.SetValidation(fluentValidation.GetValidations()); }
public async Task <Playlist> ObterRecomendacaoPlaylistPorLatitudeELongitude(string latitude, string longitude) { var coordenadas = new Coordenadas(latitude, longitude); if (!coordenadas.IsValid()) { return(ValidationBase.TratarMensagemErro <Playlist>(coordenadas.MensagensErro)); } var cidade = await new OpenWeatherMapsProvider().ObterTemperaturaPorLatitudeELongitude(coordenadas); if (!cidade.IsValid()) { return(ValidationBase.TratarMensagemErro <Playlist>(cidade.MensagensErro)); } var playlist = await new SpotifyProvider().ObterRecomendacaoPlaylistPorCategoria(cidade); return(playlist); }
public virtual async Task <IActionResult> ProvideReconciliationData([FromBody] ReconciliationRequest model) { ValidationResult validation = new ValidationBase().ReconciliationData(model); if (validation != ValidationResult.Success) { return(BadRequest(new { error_occured = true, error_message = validation.ErrorMessage })); } try { var response = await _payment.ProvideReconciliationData(model); return(Ok(response)); } catch (Exception) { return(BadRequest(new { error_occured = true, error_message = "Unknown Error Occured" })); } }