Base solution for your next web application

Activities of "ddnils"

Hey, I have tested

System.Threading.Thread.CurrentThread.CurrentUICulture

and LanguageManager through injection:

private readonly Abp.Localization.LanguageManager _lanManager;
_lanManager.CurrentLanguage

both work pretty much the same for me.

I usually use a newPerson in $scope and bind its properties to my newForm directly so that the object is filled through angular.

To prefill use this: var emptyPerson = { name: "", age: 0 } $scope.newPerson = jQuery.extend({}, emptyPerson); // makes a copy of the object

hope this helps

Question

Hi there, i would like to seed permissions into my database. Since there is no IPermissionDefinitionContext available when working with InitialDataBuilder, I do not know how to do that. Do I have to create my own AuthorizationProvider for that? Any advice would be awesome.

Answer

Thank you, that worked (though I am not able to use IPermissionDefinitionContext).

I have set up Permission "Administration" like so: _context.Permissions.Add(new RolePermissionSetting { Name = "Administration", IsGranted = true, RoleId = 2 });

But when adding the Permission to NavigationProvider, like this: context.Manager.MainMenu .AddItem( new MenuItemDefinition( "Administration", new LocalizableString("Administration", "[MyAppName]"), // I use the Const here icon: "fa fa-cogs", requiresAuthentication: true, requiredPermissionName: "Administration" ));

I see an error in Developer Tools: <a class="postlink" href="http://localhost:6334/AbpScripts/GetScripts">http://localhost:6334/AbpScripts/GetScripts</a> Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Logs say this: ERROR 2015-10-13 10:20:08,845 [9 ] .Mvc.Controllers.AbpHandleErrorAttribute - Abp.AbpException: There is no permission with name: Administration

DB looks like this: 3 Administration True 13.10.2015 10:18:07 NULL 3 NULL RolePermissionSetting 4 Administration True 13.10.2015 10:18:07 NULL 4 NULL RolePermissionSetting

Something is still missing here, any advice?

Answer

So it seems I did misunderstand Permissions persistence.

I thought the permissions created through AuthorizationProvider.SetPermissions would be persisted inside AbpPermissions. But it seems they have to be created inside my AuthorizationProvider. For me that's a little strange. Why don't you persist the Names and Localisations to the Database (i.e. AbpPermissionNames)?

Also the error handling for the navigation menu (NavigationProvider) feels awkward. GetScripts fails completely when the Permission cannot be found. Would you mind, if I change this in Github? Or open an Issue on this?

Have you considered using

    private readonly UserManager _userManager;

in your Controller (use DI to get the actual Manager)?

this should give you: _userManager.GetUserByIdAsync()

Have a look at Entity Framework.

You can pretty much use either. If you just want Many to Many relationship, thats possible by just creating your Entities the right way:

public class Article: Entity<long> {
  public  long Id {get;set;}
  ...
  public virtual ICollection<Tag> Tags {get;set;}
}

public class Tag: Entity<long> {
  ...
  public virtual ICollection<Article> Articles {get;set;}
}

This should work. (EF creates your tables)

But if you want your relationship table to have additional fields (ie. CreationDate) you need to use FluentApi.

See this document for help: <a class="postlink" href="http://www.entityframeworktutorial.net/code-first/configure-many-to-many-relationship-in-code-first.aspx">http://www.entityframeworktutorial.net/ ... first.aspx</a>

Hello Vitor, I would recommend you to use Azure on one App, it pretty much scales itself. - You usually don't need to split it.

I do use continuous integration with VS Online (took me about 1h to set up). One of the best features is, that it does all the testing before it provisions to azure web. - So if you use testing, this is a good option for you. But it has it's merits too. I once tried to publish a website with visual studio which was at the same time connected via continuous integration. This went horribly wrong and I worked for hours to get back a working version.

So my recommendation is to use continuous integration, if you do test a lot. (If you use a msdn subscription for the licensing be aware of the 5 builds per day limit). If not, you can use VS to publish to azure, it's easier to maintain.

Question

Hi there, i would like to allow anonymous access to my home site. But it seems navigation is dependent on a valid User since it throws me an error saying: No User is logged in.

I have provided HomeController with [AllowAnonymous] Attribute. Any ideas on this matter?

I have been trying to wrap my mind around the localization features of angular.

Since the razor-views do a lot of the heavy lifting, I am able to localize pretty much every string. My main concern is the localization of dates. When using angular to display dates, I usually do it with a filter like this:

<div>{{scopeValueDate | date: 'shortDate'}}</div>

This works pretty well as expected, but when i activated additional languages I noticed the dates were not localized.

It seems the angular resources for internationalization are not loaded. (/Scripts/i18n/angular-locale_XX.js) They do not appear in Developer Tools / Sources.

Also I am not able to insert them into the page... If I do add a script reference, the script is still not visible in Developer Tools.

Have you experienced anything similar? How do you solve internationalization of dates?

Showing 11 to 20 of 28 entries