Base solution for your next web application

Activities of "cyklussoftware"

I am on ASP.NET Core + jQuery v5.2.

Bug: When adding a user to an Organization Unit through the web GUI, all of the previously created users (users were created manually through the Users GUI) are added to the Organization Unit, regardless of the selected user.

Steps to reproduce bug: Create a new user (create one or more using the Admin account for the Default tenant) Go to Administration > Organization Units Assign a user to any Organization Unit Notice that more than the just the selected user is added to the Organization Unit.

Is this bug reproducible? Or did I mess something up somewhere?

I am using ASP.NET Core v5.3 jQuery.

I am trying to extend the OrganizationUnit entity to include a boolean called IsOrganizer. I followed the Non-Abstract part of the Extending Entities tutorial to the best of my ability, but ultimately I couldn't follow it for various reasons (not applicable to OrganizationUnit, seems old or for angular version, etc).

So, does anyone have any guidance?

The things I did so far:

  • Created a new class called ExtendedOrganizationUnit (for lack of a better name) that inherits from OrganizationUnit

  • Added the new DbSet for ExtendedOrganizationUnit to the DbContext.

  • Added the added a migration

  • Updated the database (saw the change successfully)

  • Edited the OrganizationUnitDto to include my IsOrganizer boolean.

  • Edited the CreateOrganizationUnitInput to include my IsOrganizer boolean

  • Edited the UpdateOrganizationUnitInput to include my IsOrganizer boolean

  • I added a check-box input control to the _CreateModal and _EditModals

Now, I know I need to do something with the CreateOrganizationUnit and UpdateOrganizationUnit methods of the OrganizationUnitAppService. I'm not sure if I need to do anything to the GetOrganizationUnits method.

I think I also need to do something with the following:

  • CustomDtoMapper, but I'm not sure what to add / remove.
  • EditOrganizationUnitModalViewModel - I need to add the IsOrganizer bool and an AutoMapFrom setting.
  • OrganizationUnitsController - I think I need to case the OrganizationUnit to my custom variant.

What am I missing? Is there anything that I DIDN'T need to change?

Great! Thanks for the detailed answer.

I am getting an error when trying to create a new OrganizationUnit with the _CreateModal.cshtml (with my added check-box)

The error says "Your request is not valid! The following errors were detected during validation. -"

Is there some javascript file that I need to change?

Turns out this is only a problem if the CheckBox is checked. If it is unchecked, the form saves correctly.

Alright, sorry for the large number of posts, but I got it to work. Turns out the checkbox was returning the value of "on/off" instead of "true/false" which threw everything off.

In my _CreateModal I added the 'value' attribute to the checkbox and set 'value="true"'. Setting the value to true doesn't set the checkbox to checked/unchecked, but I guess it triggers it to return true/false instead of on/off.

Then in my _EditModal, I added an @Html.EditorFor(x => x.IsOrganizer). Now the checkbox is properly checked and unchecked and returns the proper true/false value.

I am using ASP.NET Core + jQuery v5.3

The following is a snippet from the Index.js of my GeneralEvent entity (generated by RAD Tool). The snippet is part of the DataTable() function. Specifically the "items" of the "rowAction" of the "columnDefs".

items: [
	{
		text: app.localize('View'),
		action: function (data) {
			_viewGeneralEventModal.open({ data: data.record });
		}
	},
	{
		text: app.localize('Edit'),
		visible: function (data) {
			var eventObject = data.record.generalEvent;

			abp.services.app.generalEvents.hasPermissionForEntity(eventObject)
				.done(function (result) {
					var hasPermission = result;
					console.log(hasPermission);
					//return result; // I would like to return this value. This obviously won't work
				});

			//return _permissions.edit; // original code
		},
		action: function (data) {
			_createOrEditModal.open({ id: data.record.generalEvent.id });
		}
	},

OK, so hopefully you know what I'm talking about now.

I am making a sort of custom permissions system that is based on OrganizationUnits. Basically, a user can only see the Create/Edit menu option in the RowAction dropdown if he has belongs to the OrganizationUnit of the Event.

I know the "visible" attribute is set using the anonymous function. How would I return a value from my app service? I know what I have above doesn't work because it's asynchronous, but it shows what I'm trying to do.

I guess my question becomes this: How would I set the "visible" property of the RowAction dropdown once my data has been calculated in my AppService?

Thanks!

Question

I am using ASP.NET Core + jQuery v5.3.

I am looking at creating a public-facing API so that calendar services like Google Calendar or Outlook can request an ICS representation of a set of Event entities from our DB.

I will be generating the individual URLs for accessing the API within the application, so we will know the user's ID and the tenant's ID. We can embed this information into the URL and the API will know what to access.

The question ultimately becomes, with ASP.NET Zero / ASP.NET Boilerplate, how would I create an API that DOESN'T require the user to log in? Would I just use the normal ASP.NET Core way or is there a better way?

Thanks!

Answer

Right. I see AllowAnonymous for MVC controllers and AbpAllowAnonymous for AppService methods, but how do I access a specific repository without having a logged in user? Is there any build-in system for this? Or will it need to be a custom system like: access host DB, look for tenant DB based on URL parameter, then access tenant DB?

Answer

I know about the GET request header called "Abp.TenantId", but because I want to return an ICS file using the URL ONLY and NOT through a GET request, I am having trouble.

I could create an [AllowAnonymous] MVC Controller method that takes in the tenantId as a parameter. The method can create and execute a new GET request with the Abp.TenantId header set. This will give me access to the AppService and its repositories. Once the [AllowAnonymous] MVC Controller method has the JSON data from the AppService's response, I can parse it and return the file.

Is there a better way to do this?

I am using the ASP.NET Core + jQuery v5.4.1 project.

I have been using the included AppService Unit Tests to test my custom AppServices and helper classes. This is great for verifying that my logic is sound at a low level.

That said, I have found that it is helpful to test the entire application from top to bottom. I have found that some of the edits I make to generated Javascript files and/or MVC Controllers break the application while my AppServices run just fine (failures are due to incorrect Dto mappings, etc). I have been doing this "top to bottom" UI testing manually so far.

I have been doing some reading, and it is easy enough to run the ASP.NET Core project on my local machine and run a Test Project that has Selenium WebDriver tests implemented. This would automate my UI test process nicely. The only problem is that running the ASP.NET Core project from command line still instructs it to use the Default connection string, which is a SQL Server LocalDB instance. To automate tests I would need to delete the LocalDB, re-create the LocalDB, and then run the Migrator before testing again. This is long and annoying.

I was wondering if anyone here might have any ideas on how to do an "in-memory" temporary database (like the one implemented for the Unit Tests), but for Selenium UI tests. Any ideas (or alternative approaches) are appreciated.

Showing 11 to 20 of 42 entries