Base solution for your next web application

Activities of "carelearning"

Here is the webapi controller:

namespace MyCompanyName.AbpZeroTemplate.Web.Controllers.api
{
    using Abp.WebApi.Controllers;
    using Departments;
    using Departments.Dto;
    using Domain;
    using Models.Dto;
    using System;
    using System.Collections.Generic;
    using System.Web.Http;

    public class DepartmentController : AbpApiController
    {

        public DepartmentController()
        {

        }

        [HttpGet]
        public IHttpActionResult Get()
        {
           var departments;
        //retrieve data and pass it on--this works
            return Json(departments);           
        }


//This fails with a 500 error:
        [HttpDelete]
        public void Delete(DeleteItem item)
        {
            if (!String.IsNullOrWhiteSpace(item.key))
                _departmentAppService.Delete(item.key);
        }

    }
}

We tried the [FromBody] attribute and received the same result.

Thanks

We are using DevExtreme's dxDatagrid which currently posts back to API controller methods with content-type of "application/x-www-form-urlencoded." If we try to invoke this grid's actions, then we get a 500 server error.

We get this error: nHandling.AbpApiExceptionFilterAttribute - Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details. System.Web.Http.HttpResponseException: Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details. at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken) at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable1 formatters, IFormatterLogger formatterLogger) at System.Web.Http.ModelBinding.FormatterParameterBinding.<ExecuteBindingAsyncCore>d__0.MoveNext()

When we invoke the action using Fiddler with JSON then it works perfectly. Is there a way to allow

abp.services.app.[controller].[action]()

to submit as "application/x-www-form-urlencoded"?

We have also asked DevExpress for any way to make their control encode using JSON here (this shows code snippets if needed).

Answer

Do you know yet if the Angular2 version will be developed to work with Angular CLI (<a class="postlink" href="http://cli.angular.io">http://cli.angular.io</a>)? Thank you for the hard work. We are excited about the AspNet Core and Angular2 versions!

Question

Since Angular2 just recently went to beta, we thought we would try to move in that direction. Has any thought or effort been put into using Angular2 within Asp.Net Zero? We have been reading about ngUpgrade: <a class="postlink" href="http://blog.thoughtram.io/angular/2015/10/24/upgrading-apps-to-angular-2-using-ngupgrade.html">http://blog.thoughtram.io/angular/2015/ ... grade.html</a> Has anybody else tried to do anything like this?

Answer

Thank you very much your reply!

We have implemented the code you posted and it works great!

Thank you again for your hard work.

careLearning-Bill

Question

Hello,

We have a need to have the left navigation bar render differently based on features and permissions per tenant. For example we added this to AppNavigationProvider.cs,

if (_featureChecker.IsEnabled(IndividualConstants.FeatureName)) {
	context.Manager.MainMenu.AddItem(new MenuItemDefinition(
    	PageNames.App.Tenant.Individual,
    	L("Tenants"),
    	url: "tenant.individual",
    	icon: "icon-users"));
}

However, we receive the following error: FeatureChecker can not get a feature value by name. TenantId is not set in the IAbpSession!

Is there a way to dynamically generate navigation based on features and permissions? We were thinking about declaring the menu items in the client. Do you have any advice or know of any pitfalls?

careLearning-Bill

This workaround involves creating a static method in my module IndividualConstants class and adding a using statement in the view. I am not sure this is the optimal solution but it does work.

public class IndividualConstants
{
   public const string LocalizationSourceName = "Individual";

   public static ILocalizableString Ls(string name) => new LocalizableString(name, LocalizationSourceName);
   public static string L(string name) => Ls(name).Localize();
}
@using Individuals
<div>
    <form class="form-validation" name="createIndividualForm" novalidate role="form">
        <div class="modal-header">
            <h4 class="modal-title">@IndividualConstants.L(IndividualConstants.IndividualCreate)</h4>
        </div>
        <div class="modal-body">
            <div class="form-group">
                <label for="Name" class="control-label bold">@L("Name")</label>
 

Following the guidelines from module system we have incorporated several of the providers in the module including Localization. See code below.

public class IndividualModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.Authorization.Providers.Add<IndividualAuthorizationProvider>();
            Configuration.Features.Providers.Add<IndividualFeature>();

            Configuration.Localization.Languages.Add(
                new LanguageInfo("en", "English", "famfamfam-flag-us", true));

            Configuration.Localization.Sources.Add(
                   new DictionaryBasedLocalizationSource(
                       Constants.LocalizationSourceName,
                       new XmlEmbeddedFileLocalizationDictionaryProvider(
                           Assembly.GetExecutingAssembly(),
                           Constants.ResourceSource)
                       )
                   );

            Configuration.Navigation.Providers.Add<IndividualNavigationProvider>();
            base.PreInitialize();
        }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
        }
    }

The question arises when using @L("Individual") in our Razor CSHTML for the AngularJS view it is using the base LocalizationSourceName value . We need to reference the base localization dictionary and that specific module's version too in the same view.

To illustrate createPersonModal.cshtml the first usage line #6 I'd like to say something like @L("CreateNewPerson", "Individual") where the second parameter is the module's dictionary. In contrast line #28 @L("SavingWithThreeDot") remains the same as it needs to reference the base localization dictionary defined in Core.

PS ASP.NET Zero is an awesome Starter Template/Framework and the code is of high quality.

Showing 101 to 108 of 108 entries