Exemple #1
0
        private void Validation(CaseEx request, FieldConfigInfo fieldConfig)
        {
            if (string.IsNullOrWhiteSpace(request.RecordType))
            {
                throw new BadRequestException("RecordType is missing from request or empty",
                                              new LogObject("CaseValidationTask_ExecuteAsync", null));
            }


            var properties = CaseRepository.GetProperties(request);
            //check to be sure that they pass data to un-used fields for a specific case
            var notUseFields = properties.Where(p => fieldConfig.Fields.All(f => f.Name != p.Name));

            CaseRepository.ValidateNotAllowedFields(notUseFields, request);
            foreach (var field in fieldConfig.Fields)
            {
                CaseRepository.ValidateField(request, field);
            }
        }
 private void SetProperty(CaseEx request, FieldConfigInfo fieldConfig)
 {
     foreach (var field in fieldConfig.Fields)
     {
         try
         {
             var property     = CaseRepository.GetProperty(field.Name, request);
             var currentValue = property.GetValue(request, null);
             if (!string.IsNullOrWhiteSpace(field.DefaultValue) &&
                 (string.IsNullOrWhiteSpace(currentValue?.ToString())))
             {
                 property.SetValue(request, field.DefaultValue);
             }
         }
         catch (Exception ex)
         {
             throw new GdErrorException($"Error setting default value for Field={field.Name}",
                                        new LogObject("SetDefaultValueTask_SetProperty",
                                                      new Dictionary <string, object> {
                 { "FieldName", field.Name }
             }), ex);
         }
     }
 }