EzDev.org

aspnetboilerplate

aspnetboilerplate - ASP.NET Boilerplate - Application Framework ASP.NET Boilerplate - Web Application Framework an application framework and starting point for asp.net mvc web applications with best practices and most popular tools!


common roles for all tenants in AspNetBoilerplate

I have a custom set of roles that is supposed to be used in a multi-tenant app.

AbpRoles table has a column titled "TenantId" (nullable).

Problem is that if I leave this field with a null value, a user per certain tenant cannot be recognized as being related to a certain role. But if an AbpRole record has tenant id value - all works pretty well.

The bottomline is:

my code has to be creating the same set of roles for each tenant, so I'm just wondering if it's possible to have common set of roles for all tenants.

If the TenantId value is null for AbpRole record and I wrap the code that checks if user belongs to a role

User.IsInRole("Employee")

into this block

using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant))

the problem is still not solved.


Source: (StackOverflow)

An error has occurred! Error detail not sent by server

I am using asp.net core with boilerplate framework. While implementing save functionality, I am getting "An error has occurred! Error detail not sent by server." error on production server. On debugging, I found that the control gets to .fail() function instead of going to .done() function. The record gets saved into the database and I am getting following message on pop-up : "An error has occurred! Error detail not sent by server."

Following is the jquery used:

this.save = function (modalManager) {
            debugger;
            _$Form = _modalManager.getModal().find('form[name=FormName]');
            var orderTemplateId = $("#orderTemplateId").val();
            var OrderTemplate = _$Form.serializeFormToObject();
            _modalManager.setBusy(true);
            debugger;

            OrderTemplate.id = orderTemplateId;
            var AssignedProductsIds = _findAssignedProductList();
            debugger;
            _orderTemplateService.createOrUpdateOrderTemplate({
                OrderTemplate: OrderTemplate,
                AssignedProductsIds: AssignedProductsIds,
            }).done(function (result) {
                debugger;
                abp.notify.info(app.localize('SavedSuccessfully'));
                _modalManager.close();                
            }).fail(function (result) {
                debugger;                    
                _modalManager.close();
            }).always(function (result) {
                _modalManager.setBusy(false);
                window.location.href = '/app/zone';
            });            
        };

The functionality works perfectly on local server without any errors. So, I am not getting where I am going wrong?

Thanks.


Source: (StackOverflow)

EF Core Migration with aspnetboilerplate Where to trigger context.Database.Migrate();

I need to ensure my application itself is able to upgrade his database model (apply migrations)

In the ABP architecture, where should I make the call to Migrate?

context.Database.Migrate();

As this is a call to a infraestructure logic (Entity framework Core) it should be kept out from domain services and application services.

Thanks in advance


Source: (StackOverflow)

Compilation Error : CS0308 The non-generic type 'PermissionChecker' cannot be used with type arguments

After upgrading nuget packages to v2.1.3 I am getting this error on compilation. I am using latest ASP.NET Boilerplate template.

Error : CS0308 The non-generic type 'PermissionChecker' cannot be used with type arguments Project: MembershipMgmt.Core Class: MembershipMgmt.Authorization.PermissionChecker


Source: (StackOverflow)

Asp.Net Boilerplate, How to apply queries on database tables?

I am using Asp.Net boilerplate framework, I created a table in database by Code-First approach. Now i want to get Records from that table but applying query like this returning empty data. Why?

 MyAppDbContext db = new MyAppDbContext();
 var list = db.NewTables.ToList();

But List is returned as empty while table contains data actually.


Source: (StackOverflow)

ASP.NET Boilerplate - Error building new project for MVC and EF combo

I have just downloaded, today, the free startup template for MVC5 and EF. On opening, restoring all packages then building, I get the following build error in the "Core" project:

Error CS0508 'AppSettingProvider.GetSettingDefinitions(SettingDefinitionProviderContext)': return type must be 'IEnumerable' to match overridden member 'SettingProvider.GetSettingDefinitions(SettingDefinitionProviderContext)'

Error CS0012 The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

As the error message suggested, I added the reference to the assembly, however, that produced a whole lot of other errors.

Looking at the sample projects, they are using v2.1.3 of the APB assemblies and they compile fine.

The latest downloaded sample uses v3.0.0 of the APB assemblies.

Any help to get this up and running is appreciated. Thanks in advance.


Source: (StackOverflow)

Mocking the UnitOfWorkManager.Current in a unit test

When unit testing, the system cannot resolve UnitOfWorkManager.Current (nullreference exception). The _unitOfWorkManager is of type: IUnitOfWorkManager, and injected via DI.

I'm testing the following web api code:

[HttpPost]
public async Task<IHttpActionResult> Subscription(SubscriptionInputDto model)
{
    if (!await VendorHasAccess(model.OrganizationId))
        return StatusCode(HttpStatusCode.Forbidden);

    var input = new Subscription
    {
        ...
    };

    var data = await _subscriptionRepository.InsertAsync(input);

    await _unitOfWorkManager.Current.SaveChangesAsync();

    return Ok(data.MapTo<SubscriptionDto>());
}

…with the following unit test:

[Fact]
public async Task Should_Create_New_Subscription()
{
    //Arrange
    var organization = await UsingDbContextAsync(async context => await context.VendorOrganizations.FirstOrDefaultAsync());
    var input = new SubscriptionInputDto { OrganizationId = organization.Id };

    //Act
    var actionResult = await _vendorController.Subscription(input);
    var response = actionResult as OkNegotiatedContentResult<SubscriptionDto>;

    //Assert
    Assert.NotNull(response);
    Assert.Equal(organization.Id, response.Content.OrganizationId);
}

I cannot figure out, or find any documentation on, how to resolve the UnitOfWorkManager.Current so that it doesn't fail for the unit test. The web API code itself works in production.

Any tips?


Source: (StackOverflow)

The type 'Object' is defined in an assembly that is not referenced

This is the first time I have used abp to build a project using templates. I tried a lot of ways to find out how to fix this problem but failed.

  • Abp package version: 3.0.0
  • Base framework: .Net Framework 4.6.1

Exception: The type 'Object' is defined in an assembly that is not referenced.You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.


Source: (StackOverflow)

ASPNETZERO - UI Template change

My client does not like the Metronic UI provided in the ASPNETZERO template. He is looking into getting something custom designed by a UI/UX designer or purchasing another UI template. I wanted to find out if anyone else has done this change with ASPNETZERO and I wanted to ask some questions around this process.

  • Have you completely removed Metronic template from ASPNETZERO and used another UI template?
  • What challenges did you run into?
  • How much effort did it take?

Any tips, tricks and advice that you can share on making this change would be much appreciated!


Source: (StackOverflow)

How to get username after login redirect is Aspnet Boilerplate?

I have 2 applications: one does the login (app1) and another one does other stuff that I want (app2). The app1 is build in aspnet boilerplate and what I want to do is after login in with this app I want to redirect to the app2. Until now is everything fine, I just used the returnUrl parameter to redirect to the app2. The problem is that I want to pass to app2 some of the login information like username. It's not supposed to me change anything in app1 so, how can I do that?

The app2 is built in MVC 5.


Source: (StackOverflow)

Net standard Library missing reference in ASP.NET Boilerplate

every time i clone Abp.ModuleZero to my machine when i run nuget command update-database the error show me and when i build the solution in viusal studio the project doesn't build and show many errors in error list console window most of them is like :

The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

i try to install Netstandard.library package from package manager console window but doesn't any sense.

my visual studio IDE version is 2015 Update 3.


Source: (StackOverflow)

ASP.NET BoilerPlate: .Net core template - app service error

I am in the process of moving my app code from the .Net5 MVC/JQuery ASPNETZERO template to the new .Net core 1.1 MVC/JQuery template. So far I have copied over my first few custom entities. Created a EF migration and applied the changes to my DB. I then started building the first app service for one of my entities. I am copying over the code from my existing MVC template that is working without any issues.

      public async Task<PagedResultDto<ListValuesListDto>> GetListValues(GetListValuesInput input)
    {
        var query = from lv in _listvaluesRepository2.GetAll()
                    select new ListValuesListDto
                    {
                        Id = lv.Id,
                         ListName = lv.ListName,
                         ListText = lv.ListText
                    };
        query = query.WhereIf(!input.Filter.IsNullOrWhiteSpace(), lv => lv.ListName.Contains(input.Filter) || lv.ListText.Contains(input.Filter));
        var resultCount = await query.CountAsync();
        var results = await query.OrderBy(input.Sorting).PageBy(input).ToListAsync();
        return new PagedResultDto<ListValuesListDto>(resultCount, results);
    }

The method above is from my MVC template. When I place this into the .Net core solution, I keep getting the following build error.

CS0411 The type arguments for method 'Enumerable.OrderBy(IEnumerable, Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly

The error is pointing to the "OrderBy" on this line of code:

      var results = await query.OrderBy(input.Sorting).PageBy(input).ToListAsync();

I am still very much learning the ABP template and EF. I cannot for the life of me figure out why the same code in the .Net core template does not work?

Any help that anyone can provide would be much appreciated!


Source: (StackOverflow)

Foreign Key Reference Object Returning Null [closed]

I am referencing the AbpUser table in an entity with the following entity definition:

[ForeignKey("LocationManagerId")]
public virtual User LocationManager { get; set; }
public virtual long LocationManagerId { get; protected set; }

My DTO is as follows:

[AutoMapFrom(typeof(Location))]
public class LocationDto : FullAuditedEntityDto<Guid>
{
    <snip>
    public virtual User LocationManager { get; set; }
}

Using the AsyncCrudAppService and calling the following from an MVC controller:

var locations = (await _locationAppService.GetAll(new PagedAndSortedResultRequestDto())).Items;

locations.LocationManager is returning null. I've confirmed everything in both the entity and the dto is set to virtual. I'm at a loss. Anyone have any insight?


Source: (StackOverflow)

ASP.NET Boilerplate Angular Project Error when npm start

I use ASP.NET Boilerplate Framework that is based on .Net Core and Angular. I follow directives in this page step by step but when I run npm start I get the following error message:

ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'web-animations-js' in'D:\Project_Net\MyProjSPA\angular\src'
resolve 'web-animations-js' in 'D:\Project_Net\MyProjSPA\angular\src'
  Parsed request is a module
  using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./src)
    resolve as module
      D:\Project_Net\MyProjSPA\angular\src\node_modules doesn't exist or is not a directory
      D:\Project_Net\MyProjSPA\node_modules doesn't exist or is not a directory
      D:\Project_Net\node_modules doesn't exist or is not a directory
      looking for modules in D:\Project_Net\MyProjSPA\angular\node_modules
        using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./node_modules)
          using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./node_modules/web-animations-js)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js.js doesn't exist
            as directory
              D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js doesn't exist
      looking for modules in D:\node_modules
        No description file found
        Field 'browser' doesn't contain a valid alias configuration
        No description file found
        no extension
          Field 'browser' doesn't contain a valid alias configuration
          D:\node_modules\web-animations-js doesn't exist
        .ts
          Field 'browser' doesn't contain a valid alias configuration
          D:\node_modules\web-animations-js.ts doesn't exist
        .js
          Field 'browser' doesn't contain a valid alias configuration
          D:\node_modules\web-animations-js.js doesn't exist
        as directory
          D:\node_modules\web-animations-js doesn't exist
      looking for modules in D:\Project_Net\MyProjSPA\angular\node_modules
        using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./node_modules)
          using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./node_modules/web-animations-js)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js.js doesn't exist
            as directory
              D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js doesn't exist
      looking for modules in D:\Project_Net\MyProjSPA\angular\src
        using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./src)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./src)
          using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./src/web-animations-js)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              D:\Project_Net\MyProjSPA\angular\src\web-animations-js doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              D:\Project_Net\MyProjSPA\angular\src\web-animations-js.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              D:\Project_Net\MyProjSPA\angular\src\web-animations-js.js doesn't exist
            as directory
              D:\Project_Net\MyProjSPA\angular\src\web-animations-js doesn't exist
      looking for modules in D:\Project_Net\MyProjSPA\angular\src
        using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./src)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./src)
          using description file: D:\Project_Net\MyProjSPA\angular\package.json (relative path: ./src/web-animations-js)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              D:\Project_Net\MyProjSPA\angular\src\web-animations-js doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              D:\Project_Net\MyProjSPA\angular\src\web-animations-js.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              D:\Project_Net\MyProjSPA\angular\src\web-animations-js.js doesn't exist
            as directory
              D:\Project_Net\MyProjSPA\angular\src\web-animations-js doesn't exist
[D:\Project_Net\MyProjSPA\angular\src\node_modules]
[D:\Project_Net\MyProjSPA\node_modules]
[D:\Project_Net\node_modules]
[D:\node_modules\package.json]
[D:\node_modules\web-animations-js\package.json]
[D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js]
[D:\node_modules\web-animations-js]
[D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js.ts]
[D:\node_modules\web-animations-js.ts]
[D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js.js]
[D:\node_modules\web-animations-js.js]
[D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js]
[D:\node_modules\web-animations-js]
[D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js]
[D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js.ts]
[D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js.js]
[D:\Project_Net\MyProjSPA\angular\node_modules\web-animations-js]
[D:\Project_Net\MyProjSPA\angular\src\web-animations-js]
[D:\Project_Net\MyProjSPA\angular\src\web-animations-js.ts]
[D:\Project_Net\MyProjSPA\angular\src\web-animations-js.js]
[D:\Project_Net\MyProjSPA\angular\src\web-animations-js]
[D:\Project_Net\MyProjSPA\angular\src\web-animations-js]
[D:\Project_Net\MyProjSPA\angular\src\web-animations-js.ts]
[D:\Project_Net\MyProjSPA\angular\src\web-animations-js.js]
[D:\Project_Net\MyProjSPA\angular\src\web-animations-js]
 @ ./src/polyfills.ts 36:0-27
 @ multi ./src/polyfills.ts

Here are my framework versions:

npm -v // 3.10.10
node -v // 6.11.3
tsc -v //2.5.3
ng -v // @angular/core 4.4.4
angular-cli version in `package.json` : //@angular/cli": "^1.3.2"

I think it's related to angular version or typescript version.Am I right? What should I do to resolve this problem?


Source: (StackOverflow)

Should I be calling an AppService from another AppService?

Context

Currently I'm working in a Documents and Records Management System (DRMS?). Because of some technical limitations I need to store a "view" file and a "source" file (DOCX or XLSX). A view file is a PDF file for users to print, download and view for every day usage while a source file is the editable file. When users require to update a file, they will download the source, update it, and upload a new view file and the corresponding source file.

I'm not able, at this time, to implement XLSX viewers/editors and, due to the quantity of files, I cannot migrate to ODFs in order to use open source viewers available.

Right now I have two models like this:

public class Document {
    //Other fields
    public virtual List<DigitalFile> Files { get; set; }
}

public class DigitalFile {
    //Other fields
    public virtual Document FileOf { get; set; }
}

The Document model has all the "business" data while the DigitalFile model has data about the files themselves (path, url, type, etc.)

Each time a document is created it will have 1 view file (required) and it may have 1 source file (some documents may not be editable). From this you can know that when a document is created/updated at least 1 digital file will be created/updated as well.

Problem/Question

I will have a DocumentAppService to handle all the CRUD operations but here's where my doubt comes, should I be calling an AppService from another AppService? I mean, when a Document is created, should the Create method call another Create method in DigitalFileAppService? Or should it be better if DocumentAppService handled everything on its own?

Right now all the CRUD operation on DigitalFile are tied to the operations on Document, which is why I'm in doubt of implementing an AppService for the files.


Source: (StackOverflow)