Base solution for your next web application

Activities of "alukaszewski"

Do you please have an example of setting a default value for a new integer property in the constructor?

What is "EF" ?

Where do I set a default value in the constructor of a User? Is there an example? I was looking to see how existing code works but I cannot find any existing property which uses an integer and sets a default value.

I'm not creating a new Entity, I'm extending the existing User Entity by adding additional property.

If I set a value of 300, this is saved and retrieved fine by the user settings modal and the user edit modal. Here is what I have in my Migration;

public partial class Added_RefreshInterval_To_User : DbMigration
    {
        public override void Up()
        {
            AddColumn("dbo.AbpUsers", "RefreshInterval", c => c.Int(nullable: false, defaultValue: 300));
        }
        
        public override void Down()
        {
            DropColumn("dbo.AbpUsers", "RefreshInterval");
        }
    }

The design of the table for the "RefreshInterval" column added to the database shows as having default value of 300, but a value of 300 is not displayed by new user modal or set when a new user is created by LDAP Auth.

I believe problem is that the LDAP user creation user process and the user create modal need to know what default value to display/use and insert into the table, otherwise it inserts 0 (zero). Does that make sense? It is no use having default value set on database table column design as the creation process is overriding this with 0.

I think you have to migrate your solution INTO a new blank 4.1 project, and make your code revisions in 4.1, either that, or review the changed files in 4.1 and make the same modifications in your existing 4.0.

I have extended the User Entity using the development guide, to add a new user setting for 'refresh interval' and a new migration is created OK, and the user can get/set this value OK. The Users table is extended OK with new column with default integer value of 300. However, when new users are created how do I set default value there instead of 0 (zero).

I think something in this line is required in the _CreateOrEditModal.cshtml to specify a default value of 300 if no value already set? I'd also wonder how to prevent value enter less than 60?

<input id="EditUser_RefreshInterval" type="text" name="RefreshInterval" class="form-control edited" value="@Model.User.RefreshInterval" maxlength="5">

Also, when new user is created by LDAP authentication - how to ensure default value of 300 is set?

If I create row manually in the database, default value is set to 300 as per the 'default value' attribute of the column - so must be in abp I am missing something?

Thanks,

Andy

I'm now having some success by simply using an AJAX POST with url: abp.appPath + 'api/services/app/profile/GetCurrentUserProfileForEdit' and storing the response in abpUser object. This returns all current user profile properties which I can then inspect via code. Is there a better way?

I'd like "AutoRefresh" true/false to be a property of the user - this is so that an Admin can pre-create a user and set this property in CreateEditUser modal AND the user can access the property from the MySettings modal. I have already got that far and I can display/set the property in those modals I mentioned.

What I am now stuck with, is how to read that value from any page or a controller action.

I'm almost getting there, I feel very close to a solution by using "abp.services.app.profile" in client side script and I see the http 200 response body containing the current user profile data - but for some reason I am unable to capture that response into an object.

OK, I'm really stuck with this one.

I am able to EXTEND an existing entity (the user) and can use the existing CreateEditUser modal and UserSettings modal to display and change the vale (it's a checkbox/boolean) - but I am lost as to HOW to retrieve that value using abp.settings (client side) or using a controller action. The stored value is in the abpUsers table.

or,

I am able to add new pre-defined User Visible settings and I can retrieve the values of these using client side abp.settings (and probably with a controller action) (these are stored in abpSettings table) but I am completely lost as to how to implement the display/changing of that value in the CreateEditUser modal or UserSettings modal.

Basically, I'd like to implement a per-user true/false setting (called AutoRefresh) that the user can access via their own settings, or the admin can set on a user account via the user editing. When a page loads, I'd like to test for that value and run code as appropriately.

I followed this guide to extend the User Entity, simply adding to User.cs and ran a migration:

<a class="postlink" href="https://aspnetzero.com/Documents/Extending-Existing-Entities">https://aspnetzero.com/Documents/Extend ... g-Entities</a>

...so I did not 'define' my new setting and there is nowhere to set IsVisibleToClients to true. Is that the wrong way to implement user-based settings, have I misunderstood? Is it possible to get the value of an extended property using SettingManager or is that only for retrieving values defined using SettingProvider?

If I follow your suggestion of defining a new setting using SettingProvider, would that then be stored in the AbpSettings table instead of AbpUsers and show user specific values for the TenantId and UserId field instead of NULL?

Can I just add additional User based settings to the AppSettingProvider.cs?

How do I get the value of a user setting using a controller? I am trying:

bool UseAutoRefresh = SettingManager.GetSettingValueForUser("UseAutoRefresh");

but Visual Studio is throwing error "No overload for method 'GetSettingValueForUser' takes 1 arguments."

I am able to use SettingManager.GetSettingValue("settingname") in the same controller without a problem - am I missing something?

Also, is it possible to directly access User Settings from Client Side JavaScript - or do I have to use Ajax call for Controller action result?

Thanks.

Showing 11 to 20 of 65 entries