Base solution for your next web application

Activities of "exlnt"

Answer

Here is an example of how I do it in my app.

     public async Task<long> CreateAddress(CreateAddressInput input)
        {
            var address = ObjectMapper.Map<Address>(input);
            if (AbpSession.TenantId != null)
            {
                address.TenantId = (int)AbpSession.TenantId;
            }
            //Create address
            var newId = await _addressRepository.InsertAndGetIdAsync(address);
            return newId;
        }

Ignore my previous message. I found the example in the user DTO class.

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (!UserName.IsNullOrEmpty())
            {
                if (!UserName.Equals(EmailAddress, StringComparison.OrdinalIgnoreCase) && ValidationHelper.IsEmail(UserName))
                {
                    yield return new ValidationResult("Username cannot be an email address unless it's same with your email address !");
                }
            }
        }

@maliming - Can you please share the documentation for that helper? I was not able to find it anywhere.

I have used the Metronic Wizard for updating multiple tables. Each step in my wizard calls a different app service and updates a different table. I think you can use the wizard to do the same for your use case.

The basic required field validation does work. It's the valid email address portion of the email address that is not working. Test it again and this time just enter a simple word for the email field and hit submit.

@maliming - Yes my repo is on GITHUB. You can see the issue on this repo. I have granted you access to the repo. Please clone and test on the branch "V7Upgrade".

@oaalvarado - If you have the below code in your js when calling the app service, it should handle the validation.

      var address = _$addressInformationForm.serializeFormToObject();
      _modalManager.setBusy(true);
      _addresssService
        .createAddress(address)
        .done(function(result) {
          abp.event.trigger("addressCreated", {
            id: result
          });
          _modalManager.close();
          abp.event.trigger("app.createAddressModalSaved");
        })
        .always(function() {
          _modalManager.setBusy(false);
        })
        .fail(function() {
          _modalManager.setBusy(false);
        });

Your app service method should be like this.

        public async Task<long> CreateAddress(CreateAddressInput input)
        {
            var address = ObjectMapper.Map<Address>(input);
            if (AbpSession.TenantId != null)
            {
                address.TenantId = (int)AbpSession.TenantId;
            }
            //Create address
            var newId = await _addressRepository.InsertAndGetIdAsync(address);
            return newId;
        }

I found a workaround. I was able to solve my issue by adding a RegEx validation attribute.

        [MaxLength(ContactConsts.EmailMaxLength)]
        [RegularExpression(CommonRegexFormats.Valid_Email, ErrorMessage = CommonRegexFormats.Valid_Email_ErrorMsg)]
        public string Email { get; set; }

        [MaxLength(ContactConsts.PhoneMaxLength)]
        [RegularExpression(CommonRegexFormats.Letters_Numbers_Space_Dash, ErrorMessage = "Phone number " + CommonRegexFormats.Letters_Numbers_Space_Dash_ErrorMsg)]
        public string Phone { get; set; }

One related question, is there any way for me to localize the error messages on my RegEx attributes shown above? I tried to use L("MyString") but it does not recognize the "L", due to reference errors. Is it ok to do in the validaton constants classes?

I have used Wizard and Tabbed Portlets from the Metronic UI for my large forms.

I have also used Profile form from Metronic UI. Try these out.

Can someone from support team respond to this question please?

Showing 1 to 10 of 316 entries