Base solution for your next web application

Activities of "andry3ag"

When creating new entities, is there any way to specify that an Id should be auto-incremented, or in the case of uniqueidentifier/GUID, invoke NEWID() as a default value?

Hi I have a few questions that would like to be answered.

1 I am trying to create multiple modules and have a core application that is compose of these multiple modules. However, it seems that a module will only expose it's controllers to the core application. When a web controller tries to deliver a view template, it tries to find the template file in the core application filesystem rather than the module's. I figured we can have a build process that copies all the frontend files to the core application, but I would like to know if there's any better approach you would recommend.

If this is the only approach, do you have a build script we can have access to?

2 Do individual module need to include module zero and all the multi tenancy, permissions, authentication logic? Can all this be simply handled from the core application so that there is only a single source of truth?

If not, how do we handle it? The examples available online do not seem to address this issue.

3 How do we handle relationships that stranded over 2 or more plugins or between plugins and the core application? For example, user having 1 to many blog entity where blog is part of the Blog plugin.

  • From which end do we address the relationship? From the core application or from the module end? Or both?

What about integer autoincrement?

Question

Hi,

how do I establish many-to-many relationship? For example, if a blog has many entries and and entry can belong to many blogs?

I tried setting doing it code first as suggested in this url <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> but when I do Add-Migration, the script do not seems to create the joining table.

Answer

I see, I will use fluent api then. Thanks alot guys.


public class Dashboard : FullAuditedEntity<int, DashboardModuleUser> { ...

    public virtual ICollection&lt;Widget&gt; Widgets { get; set; }
}

public class Widget : FullAuditedEntity&lt;int, DashboardModuleUser&gt;
{
    [ForeignKey("WidgetTemplateId")]
    public virtual WidgetTemplate WidgetTemplate { get; set; }
    public virtual int WidgetTemplateId { get; set; }

    [ForeignKey("DashboardId")]
    public virtual Dashboard Dashboard { get; set; }
    public virtual int DashboardId { get; set; }
}

So, I have the relationship above established, but when I return it to the frontend as PagedResult, it seems the Widgets in the Dashboard are not eager loading.

How should I setup to ensure my collection of Dashboards will eagerload Widgets and all my Widgets will inturn eager load WidgetTemplate BUT not Dashboard of course, else it will have circular reference issue.

My current Dto for Dashboard are set up as so:

[AutoMapFrom(typeof(Dashboard))]
public class DashboardDto : EntityDto
{
    public string Title { get; set; }

    public DashboardModuleUser User { get; set; }

    public string Content { get; set; }

    public IEnumerable&lt;Widget&gt; Widgets { get; set; }
}

Thank you.

I have successfully deployed a solution to azure but when I try to create an account on the login page the bottom of the modal displays the following message:" ERROR for site owner:Invalid domain for site key " and I cannot create a new user so I can login. I have attached the snapshot of the modal incase if its helps.

I cannot find any documentation regarding this issue. Has anyone done this before? If so, some help would be great. Do I have to deploy twice or is it better to convert the module to a NuGet package, so I only have to deploy once?

Hi!

I try to run create unit test for a custom service that inherited from IApplicationService class with permission restrictions.

Here is the steps that I took:

public static class CalendarPermission {
        public const string ListEntry = "Administration.CalendarManagement.ListEntry";
    }

    public class CalendarAuthorizationProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            var administration = context.CreatePermission("Administration");

            var calendarManagement = administration.CreateChildPermission("Administration.CalendarManagement");
            calendarManagement.CreateChildPermission(CalendarPermission.CreateEntry, null, true, null, MultiTenancySides.Tenant);
        }
    }
   public class CalenderModule : AbpModule
    {
        public override void PreInitialize() {
            Configuration.Authorization.Providers.Add<CalendarAuthorizationProvider>();
        }
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
        }
    }


 public interface ICalendarService : IApplicationService
 {
        [HttpGet]
        Task<ListResultOutput<CalendarItemDto>> GetListForCurrentUser(DateTime minDate, DateTime maxDate);
 }
 
   public class CalendarService : ICalendarService {
        private readonly IRepository<CalenderItem> calenderRepository;

        [AbpAuthorize(CalendarPermission.ListEntry)]
        public async Task<ListResultOutput<CalendarItemDto>> GetListForCurrentUser(DateTime minDate, DateTime maxDate) { ...}
}

in the unit test, I do the following:

public class CalendarItem_Tests : AppTestBase {
     private ICalendarService calendarService;

     protected override void AddModules(ITypeList<AbpModule> modules) {
            base.AddModules(modules);
            modules.Add<CalenderModule.CalenderModule>();
        }
       public CalendarItem_Tests() {
            calendarService = Resolve<ICalendarService>();
        }
        [Fact]
        public async void Test_GetCalendarItems()
        {
            LoginAsHostAdmin();
           await calendarService.GetListForCurrentUser(DateTime.MinValue, DateTime.MaxValue);
        }
}

Below are the error messages:

Abp.Authorization.AbpAuthorizationException Required permissions are not granted. At least one of these permissions must be granted: Administration.CalendarManagement.ListEntry at Abp.Authorization.PermissionCheckerExtensions.<AuthorizeAsync>d__12.MoveNext() in D:\Halil\GitHub\aspnetboilerplate\src\Abp\Authorization\PermissionCheckerExtensions.cs:line 258 --- End of stack trace from previous location where exception was thrown ---

It seems that the PermissionFinder.GetAllPermissions in the TenantRoleAndUserBuilder class is not getting the permission Administration.CalendarManagement.ListEntry.

Much appreciated for any help!

derek

I got it.

  1. you have to initialize the PermissionFinder properly as the following: PermissionFinder.GetAllPermissions(new AppAuthorizationProvider(false), new CalendarAuthorizationProvider()) since it won't pick up from the module PreInitialize method.
  2. login as tenant admin instead of hostadmin LoginAsDefaultTenantAdmin()

Regards,

derek

Showing 1 to 10 of 58 entries