Hi, I made this AppService, having a get function, but when i test the service from Swagger the input Id paramter is always null. please why is that happening?
below is an example
//input dto
public class GetRuleInput
{
public string Id { get; set; }
}
//interface
public interface ILoyaltyAppService : IApplicationService
{
Task<JObject> GetRule(GetRuleInput input);
}
//service
public async Task<JObject> GetRule(GetRuleInput input) {
var result = await _maClient.GetSingleRuleAsync(input.Id);
var response = JObject.FromObject(result);
return response;
}
Hi, I already got it to work. I suppose it had something to do with my custom repository method. Not quit sure, but its working. Do by yourself is the best way to learn!! :) :)
thanks for the support..
Hi, below was the complete stack. I already fixed this and I am no longer getting this error.
{
"message": "An error has occurred.",
"exceptionMessage": "ComponentActivator: could not proxy Abp.WebApi.Controllers.Dynamic.DynamicApiController`1[[Example.Tenants.Dashboard.ITenantDashboardAppService, Example.Application, Version=1.10.1.0, Culture=neutral, PublicKeyToken=null]]",
"exceptionType": "Castle.MicroKernel.ComponentActivator.ComponentActivatorException",
"stackTrace": " at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments)\r\n at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context)\r\n at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)\r\n at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)\r\n at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)\r\n at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)\r\n at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)\r\n at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)\r\n at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)\r\n at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy)\r\n at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy)\r\n at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary arguments)\r\n at Castle.Windsor.WindsorContainer.Resolve(Type service)\r\n at Abp.Dependency.IocManager.Resolve(Type type) in D:\\Halil\\GitHub\\aspnetboilerplate\\src\\Abp\\Dependency\\IocManager.cs:line 194\r\n at Abp.Dependency.IocResolverExtensions.ResolveAsDisposable[T](IIocResolver iocResolver, Type type) in D:\\Halil\\GitHub\\aspnetboilerplate\\src\\Abp\\Dependency\\IocResolverExtensions.cs:line 32\r\n at Abp.WebApi.Controllers.AbpApiControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) in D:\\Halil\\GitHub\\aspnetboilerplate\\src\\Abp.Web.Api\\WebApi\\Controllers\\AbpApiControllerActivator.cs:line 24\r\n at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()",
"innerException": {
"message": "An error has occurred.",
"exceptionMessage": "Can't create component 'Example.Tenants.Dashboard.TenantDashboardAppService' as it has dependencies to be satisfied.\r\n\r\n'Example.Tenants.Dashboard.TenantDashboardAppService' is waiting for the following dependencies:\r\n- Service 'Example.MultiTenancy.IPortalRepository' which was not registered.\r\n",
"exceptionType": "Castle.MicroKernel.Handlers.HandlerException",
"stackTrace": " at Castle.MicroKernel.Handlers.DefaultHandler.AssertNotWaitingForDependency()\r\n at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)\r\n at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)\r\n at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)\r\n at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernelByType(CreationContext context, ComponentModel model, DependencyModel dependency)\r\n at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernel(CreationContext context, ComponentModel model, DependencyModel dependency)\r\n at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveCore(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)\r\n at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)\r\n at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(ConstructorCandidate constructor, CreationContext context)\r\n at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context)\r\n at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)\r\n at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)\r\n at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)\r\n at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)\r\n at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)\r\n at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)\r\n at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)\r\n at Castle.Core.InterceptorReference.Castle.MicroKernel.IReference<Castle.DynamicProxy.IInterceptor>.Resolve(IKernel kernel, CreationContext context)\r\n at Castle.Windsor.Proxy.AbstractProxyFactory.ObtainInterceptors(IKernel kernel, ComponentModel model, CreationContext context)\r\n at Castle.Windsor.Proxy.DefaultProxyFactory.Create(IKernel kernel, Object target, ComponentModel model, CreationContext context, Object[] constructorArguments)\r\n at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments)"
}
}
But when I run the project, I get "An internal error occurred during your request!". Then I tried to debug it and I noticed that it fails at (code below) inside the implementation class TenantDashboardAppService
public ListResultOutput<EventLiveFeeds> GetEventLiveFeeds()
{
var events = _eventLiveFeeds
.GetAll()
.ToList();
return new ListResultOutput<EventLiveFeeds>(events.MapTo<List<EventLiveFeeds>>());
}
With an error saying "{"The entity type EventLiveFeeds is not part of the model for the current context."}". Here (code below) is my entity class. Am I doing something wrong here?
namespace Example.MultiTenancy
{
using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using System.ComponentModel.DataAnnotations.Schema;
[Table("tbl_DashboardStatistics")]
public class TenantStatistics : FullAuditedEntity, IMustHaveTenant
{
public virtual int TenantId { get; set; }
public virtual string TotalCheckins { get; set; }
public virtual string TotalWalkins { get; set; }
public virtual string TotalTransactions { get; set; }
}
public class EventLiveFeeds : Entity
{
public virtual int stars { get; set; }
public virtual string review { get; set; }
public virtual string Date { get; set; }
}
}
thanks
Hi, thanks for the reply.
first problem is naming: You named interface as 'IPotalRepository' but implementation as 'PortalRepository'. Interface name should be 'IPortalRepository'.
it was a typing error.
second one is you should directly inject and use IPortalRepository (not IRepository<EventLiveFeeds> or IPortalRepository<EventLiveFeeds>).
i had already figured that out. Also the reason why I used the IRepository in the injection was because i could not call the IPortalRepository in the application service. But I figure that out as well, by declaring my IPortalRepository in the Core layer. Which looks fine.
The issue i am having now is that, I am not able to call the GetEventLiveFeeds(), as it keeps failing. How can fix this?
"message": "An error has occurred.",
"exceptionMessage": "ComponentActivator: could not proxy Abp.WebApi.Controllers.Dynamic.DynamicApiController`1[[Example.Tenants.Dashboard.ITenantDashboardAppService, Example.Application, Version=1.10.1.0, Culture=neutral, PublicKeyToken=null]]",
"exceptionType": "Castle.MicroKernel.ComponentActivator.ComponentActivatorException",
Its also important to know that i want to be able to read sql Views and Stores procedures that is why I am using the custom repository. Also the custom repository is should use the Default database connection. I hoope I am on the right track. Below is implementation code
namespace Example.Tenants.Dashboard
{
[AbpAuthorize(AppPermissions.Pages_Tenant_Dashboard)]
public class TenantDashboardAppService : ExampleAppServiceBase, ITenantDashboardAppService
{
private readonly IPortalRepository _eventLiveFeeds;
public TenantDashboardAppService( IPortalRepository eventLiveFeeds)
{
_eventLiveFeeds = eventLiveFeeds;
}
public ListResultOutput<EventLiveFeeds> GetEventLiveFeeds()
{
var events = _eventLiveFeeds
.GetAll()
.ToList();
return new ListResultOutput<EventLiveFeeds>(events.MapTo<List<EventLiveFeeds>>());
}
}
}
thanks.
Hi, I followed the instructions on how to create a custom repository( <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/EntityFramework-Integration#DocCustomRepositoryMethods">http://www.aspnetboilerplate.com/Pages/ ... oryMethods</a> ). My assumption with dependency injection i will be able to access the new repository in my application service. But i am unable to acces it. I am not quite sure what i am doing wrong. please how can I make this work?
here is how created the custom repository namespace Example.EntityFramework.Repositories { public interface IPotalRepository : IRepository<EventLiveFeeds>, ITransientDependency { List<EventLiveFeeds> GetEventFeeds(int tenantId); }
public class PortalRepository : ExampleRepositoryBase<EventLiveFeeds>, IPortalRepository
{
public PortalRepository(IDbContextProvider<ExempleDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public List<EventLiveFeeds> GetEventFeeds(int tenantId )
{
var query = "select * from[dbo].[vw_Portal_EventLiveFeeds]";
var ret = Context.Database.SqlQuery<EventLiveFeeds>(query).ToList();
return ret;
}
}
}
here is the application service class
namespace Example.Tenants.Dashboard { [AbpAuthorize(AppPermissions.Pages_Tenant_Dashboard)] public class TenantDashboardAppService : Butiqs_PortalAppServiceBase, ITenantDashboardAppService {
private readonly IPortalRepository<EventLiveFeeds> _eventLiveFeeds;
public TenantDashboardAppService( IRepository<EventLiveFeeds> eventLiveFeeds)
{
_eventLiveFeeds = eventLiveFeeds;
}
public ListResultOutput<EventLiveFeeds> GetEventLiveFeeds()
{
var events = _eventLiveFeeds
.GetAll()
.ToList();
return new ListResultOutput<EventLiveFeeds>(events.MapTo<List<EventLiveFeeds>>());
}
}
}
kind regards