Base solution for your next web application

Activities of "PhilWynn"

Hi,

I have a requirement to apply user settings to the admin user created in TenantManager.CreateWithAdminUserAsync.

I am finding, however, that calls to SettingManager.ChangeSettingForUserAsync are not applying the settings (no error received from the call).

I have tried applying the settings in a new UOW, but still no good.

Please advise.

Hi,

I could really do with an answer on this issue. Please could you let me know if there is a way around this.

Thank you

Thank you. Managed to find a solution using a custom repository.

Hi,

Just wondering if you have been able to look into this yet?

Hi,

I am implementing a ContactManager, where a Contact is linked to a Company. Once the Contact has been created, the company should no longer be allowed to change.

I have implemented the following method in ContactManager to achieve this validation:

protected async Task<IdentityResult> CheckCompanyUnchanged(int id, int companyId)
        {
            var contact = await _contactRepository.FirstOrDefaultAsync(c => c.Id == id);
            if (contact != null && contact.CompanyId != companyId)
            {
                return AbpIdentityResult.Failed(string.Format(L("ContactCompanyChanged")));
            }

            return IdentityResult.Success;
        }

The problem I am having is that when fetching the Contact to make the comparrison, it contains the updated company value rather than the original one due to entity tracking. Is there a way to access the original values from the Core project? I know this can be done via the dbContext, but have no access to this.

Hi,

This issue is very easy to reproduce on the initial az code, e.g. creating a User:

  • Remove the 'required' attribute from a field in _CreateOrEditModal.cshtml
  • Fill in the form, leaving this field empty
  • On save, validation message comes from server
  • Now edit _CreateOrEditModal.js 'save' so that the call to userService uses abp.message.confirm
  • On save, no validation message from the server

Yes, the validation error appears in the console as expected. No javascript errors are reported. Another interesting thing to note is when I apply the following error handler:

function _attachCloseEvent() {
            _modalManager.getModal().find('.issue-close').click(function (e) {
                e.preventDefault();
                if (!_closeIssueForm.valid()) {
                    return;
                }
                abp.message.confirm(
                    app.localize('IssueCloseWarningMessage'),
                    function (isConfirmed) {
                        if (isConfirmed) {                            
                            _modalManager.setBusy(true);
                            var issue = _closeIssueForm.serializeFormToObject();
                            abp.ajax({
                                url: abp.appPath + 'Mpa/Issues/CloseIssue',
                                data: JSON.stringify({
                                    issueOutput: issue
                                }),
                                success: function () {                                    
                                    abp.notify.success(app.localize('IssueSuccessfullyClosed'));
                                    _modalManager.close();
                                    abp.event.trigger('app.itemSaved');
                                },
                                error: function () {
                                    alert('error');
                                },
                                always: (function() {
                                    _modalManager.setBusy(false);
                                })
                            });
                        }
                    }
                );
            });
        }

In this case, the validation dialog appear correctly while the alert box is shown, but when I dismiss the alert box the validation dialog disappears.

Hi,

I am using Controller Validation to validate against certain errors. The code has worked fine until I use abp.message.confirm in the save method:

function _attachCloseEvent() {
            _modalManager.getModal().find('.issue-close').click(function (e) {
                e.preventDefault();
                if (!_closeIssueForm.valid()) {
                    return;
                }
                //abp.message.confirm(
                //    app.localize('IssueCloseWarningMessage'),
                //    function (isConfirmed) {
                //        if (isConfirmed) {                            
                            _modalManager.setBusy(true);
                            var issue = _closeIssueForm.serializeFormToObject();
                            abp.ajax({
                                url: abp.appPath + 'Mpa/Issues/CloseIssue',
                                data: JSON.stringify({
                                    issueOutput: issue
                                }),
                                success: function () {                                    
                                    abp.notify.success(app.localize('IssueSuccessfullyClosed'));
                                    _modalManager.close();
                                    abp.event.trigger('app.itemSaved');
                                },
                                always: (function() {
                                    _modalManager.setBusy(false);
                                })
                            });
                    //    }
                    //}
                //);
            });
        }

When confirm is not enabled (as above) things work fine. When I enable confirm, the validation dialog box is not displayed.

Cheers, Phil

Answer

Hi,

I am not really sure how that post will help me with my current issue. I need to present the localized value of an enum on a modal form. The code I have is as follows:

public enum ProcessingType
    {
        [Display(Name = "Standard")]
        Standard = 1,
        [Display(Name = "Off cycle")]
        OffCycle = 2,
        [Display(Name = "End of year")]
        EndOfYear = 3
    }

public class HeadlineTaskDto
{
        ...
        public ProcessingType ProcessingType { get; set; }
       ...
}

public static class EnumExtensions
    {
        public static string GetDisplayName(this Enum enumValue)
        {
            return enumValue.GetType()
                            .GetMember(enumValue.ToString())
                            .First()
                            .GetCustomAttribute<DisplayAttribute>()
                            .GetName();
        }
    }

...
<div class="col-md-3">
        <div class="form-group form-md-line-input form-md-floating-label">
             <div class="form-control form-control-static">@Model.Task.ProcessingType.GetDisplayName()</div>
                <label>Type</label>
        </div>
</div>
...

I'm not sure how a client side constant would help me here?

Question

Hi,

I would like to use the Display Attribute to apply localized names to my enum value. Could you please tell me how I can do this using the AZ localization framework.

Thank you

Showing 91 to 100 of 110 entries