Hey ismcagdas,
Thanks a lot :). This works great!
Greetings,
<cite>ismcagdas: </cite> Hi,
Can you share your second DbContext definition ?
Thanks.
Hey, thanks for your response and sorry for the slow reply!
My second DB Context looks as following:
public class SecondDbContext : AbpDbContext
{
public virtual DbSet<tblRelatie> tblRelatie { get; set; }
public SecondDbContext(DbContextOptions<SecondDbContext> options)
: base(options)
{
}
}
Thanks, works like a charm :).
For others, this is what I did exactly:
Added the following class to MpaNavigationProvider.cs
public static class UserMenuItemExtensions
{
public static bool IsMenuActive(this UserMenuItem menuItem, string currentPageName)
{
if (menuItem.Name == currentPageName)
{
return true;
}
if (menuItem.Items != null)
{
foreach (var subMenuItem in menuItem.Items)
{
if (subMenuItem.IsMenuActive(currentPageName))
{
return true;
}
}
}
return false;
}
}
Updated _sidebar.cshtml
From
<div class="page-sidebar navbar-collapse collapse">
<ul class="page-sidebar-menu" data-keep-expanded="false" data-auto-scroll="true" data-slide-speed="200">
@for (var i = 0; i < Model.Menu.Items.Count; i++)
{
var menuItem = Model.Menu.Items[i];
var isActive = Model.CurrentPageName == menuItem.Name ||
(!menuItem.Items.IsNullOrEmpty() && menuItem.Items.Any(item => item.Name == Model.CurrentPageName));
<li class="@(i==0 ? "start" : "") @(isActive ? "active" : "")">
@if (menuItem.Items.IsNullOrEmpty())
{
<a href="@calculateMenuUrl(menuItem.Url)">
<i class="@menuItem.Icon"></i>
<span class="title">@menuItem.DisplayName</span>
</a>
}
else
{
<a href="javascript:;" class="auto">
<i class="@menuItem.Icon"></i>
<span class="title">@menuItem.DisplayName</span>
<span class="arrow"></span>
</a>
<ul class="sub-menu">
@foreach (var childMenuItem in menuItem.Items)
{
<li class="@(Model.CurrentPageName == childMenuItem.Name ? "active" : "")">
@if (childMenuItem.Items.IsNullOrEmpty())
{
<a href="@calculateMenuUrl(childMenuItem.Url)">
<span><i class="sub-menu-icon @childMenuItem.Icon"></i> @childMenuItem.DisplayName</span>
</a>
}
else
{
<a href="javascript:;" class="auto">
<i class="@childMenuItem.Icon"></i>
<span class="title">@childMenuItem.DisplayName</span>
<span class="arrow"></span>
</a>
<ul class="sub-menu">
@foreach (var secondLevelChildMenuItem in childMenuItem.Items)
{
<li class="@(Model.CurrentPageName == secondLevelChildMenuItem.Name ? "active" : "")">
<a href="@calculateMenuUrl(secondLevelChildMenuItem.Url)">
<span><i class="sub-menu-icon @secondLevelChildMenuItem.Icon"></i> @secondLevelChildMenuItem.DisplayName</span>
</a>
</li>
}
</ul>
}
</li>
}
</ul>
}
</li>
}
</ul>
</div>
To
<div class="page-sidebar navbar-collapse collapse">
<ul class="page-sidebar-menu" data-keep-expanded="false" data-auto-scroll="true" data-slide-speed="200">
@for (var i = 0; i < Model.Menu.Items.Count; i++)
{
var menuItem = Model.Menu.Items[i];
var isActive = Model.CurrentPageName == menuItem.Name ||
(!menuItem.Items.IsNullOrEmpty() && menuItem.Items.Any(item => item.Name == Model.CurrentPageName));
<li class="@(i==0 ? "start" : "") @(menuItem.IsMenuActive(Model.CurrentPageName) ? "active" : "")">
@*<li class="@(i==0 ? "start" : "") @(isActive ? "active" : "")">*@
@if (menuItem.Items.IsNullOrEmpty())
{
<a href="@calculateMenuUrl(menuItem.Url)">
<i class="@menuItem.Icon"></i>
<span class="title">@menuItem.DisplayName</span>
</a>
}
else
{
<a href="javascript:;" class="auto">
<i class="@menuItem.Icon"></i>
<span class="title">@menuItem.DisplayName</span>
<span class="arrow"></span>
</a>
<ul class="sub-menu">
@foreach (var childMenuItem in menuItem.Items)
{
<li class="@(childMenuItem.IsMenuActive(Model.CurrentPageName) ? "active" : "")">
@*<li class="@(Model.CurrentPageName == childMenuItem.Name ? "active" : "")">*@
@if (childMenuItem.Items.IsNullOrEmpty())
{
<a href="@calculateMenuUrl(childMenuItem.Url)">
<span><i class="sub-menu-icon @childMenuItem.Icon"></i> @childMenuItem.DisplayName</span>
</a>
}
else
{
<a href="javascript:;" class="auto">
<i class="@childMenuItem.Icon"></i>
<span class="title">@childMenuItem.DisplayName</span>
<span class="arrow"></span>
</a>
<ul class="sub-menu">
@foreach (var secondLevelChildMenuItem in childMenuItem.Items)
{
<li class="@(secondLevelChildMenuItem.IsMenuActive(Model.CurrentPageName) ? "active" : "")">
@*<li class="@(Model.CurrentPageName == secondLevelChildMenuItem.Name ? "active" : "")">*@
<a href="@calculateMenuUrl(secondLevelChildMenuItem.Url)">
<span><i class="sub-menu-icon @secondLevelChildMenuItem.Icon"></i> @secondLevelChildMenuItem.DisplayName</span>
</a>
</li>
}
</ul>
}
</li>
}
</ul>
}
</li>
}
</ul>
</div>
Yes, here it is!
[AbpAuthorize(AppPermissions.Pages_Administration_Users_Edit)] protected virtual async Task UpdateUserAsync(CreateOrUpdateUserInput input) { Debug.Assert(input.User.Id != null, "input.User.Id should be set.");
var user = await UserManager.FindByIdAsync(input.User.Id.Value);
//Update user properties
input.User.MapTo(user); //Passwords is not mapped (see mapping configuration)
if (!input.User.Password.IsNullOrEmpty())
{
CheckErrors(await UserManager.ChangePasswordAsync(user, input.User.Password));
}
CheckErrors(await UserManager.UpdateAsync(user));
try {
//Update roles
CheckErrors(await UserManager.SetRoles(user, input.AssignedRoleNames));
await UserManager.SetRoles(user, input.AssignedRoleNames);
if (input.SendActivationEmail)
{
user.SetNewEmailConfirmationCode();
await _userEmailer.SendEmailActivationLinkAsync(user, input.User.Password);
}
}catch(Exception ex)
{
throw ex.InnerException;
}
}
Btw, the CheckErrors method for update roles is the first line that throws the error
Hi,
I can't get the dto because it's somewhere in the boilerplate dll's, I haven't touched those. So when this is executed: var user = await UserManager.FindByIdAsync(input.User.Id.Value); the roles in user are indeed empty, but I can't have a good look at the FindByIdAsync method.
Thanks
Hi,
This is everything of the stacktrace I can get
StackTrace = " at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)\r\n at Abp.Authorization.Users.AbpUserManager
3.<SetRoles>d__7e.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.Compiler...
Thanks
Anyone? Still struggling with this issue....