Base solution for your next web application

Activities of "sampath"

AppNavigationProvider.cs

.AddItem(new MenuItemDefinition(
                    PageNames.App.Tenant.Dashboard,
                    L("Reports"),
                    icon: "glyphicon glyphicon-eye-open",
                    requiredPermissionName: AppPermissions.Pages_Tenant_Dashboard
                   ).AddItem(new MenuItemDefinition(
                        PageNames.App.Tenant.PropertyListingsReport,
                        L("PropertyListings"),
                        url: "tenant.propertyListingsReport",
                        icon: "glyphicon glyphicon-eye-open")
                       ).AddItem(new MenuItemDefinition(
                        PageNames.App.Tenant.BpoReports,
                        L("BpoReports"),
                        icon: "glyphicon glyphicon-eye-open")
                        .AddItem(new MenuItemDefinition(
                        PageNames.App.Tenant.PaymentReceived,
                        L("PaymentReceived"),
                        url: "tenant.PaymentReceived",
                        icon: "glyphicon glyphicon-eye-open")
                       ).AddItem(new MenuItemDefinition(
                        PageNames.App.Tenant.BankReport,
                        L("BankReport"),
                        url: "tenant.BankReport",
                        icon: "glyphicon glyphicon-eye-open")
                       ))
                )

app.js

$stateProvider.state('tenant.propertyListingsReport', {
            url: '/propertyListingsReport',
            templateUrl: '~/App/tenant/views/reports/propertyListings.cshtml',
            menu: 'PropertyListingsReport.Tenant'
        });

        $stateProvider.state('tenant.PaymentReceived', {
            url: '/PaymentReceived',
            templateUrl: '~/App/tenant/views/reports/propertyListings.cshtml',//I'll change this later
            menu: 'PaymentReceived.Tenant'
        });

        $stateProvider.state('tenant.BankReport', {
            url: '/BankReport',
            templateUrl: '~/App/tenant/views/reports/propertyListings.cshtml',//I'll change this later
            menu: 'BankReport.Tenant'
        });

Please see the image here for more details : [http://imgur.com/s2W9oT3])

Hi Halil, Yeah,If you can add JsReporting tool into ABP by default,then your framework will have huge value. Hope you'll think about it too.Good Luck ! :)

Hi Halil, Thanks a lot for the quick response. Do you have any experience with the JsReport ? Hence it's a JavaScript implementation, I think we can use it easily with the Angular.What's your thoughts about it ? Thanks in advance.

Url : <a class="postlink" href="http://jsreport.net/">http://jsreport.net/</a>

Could you suggest a good reporting tool which I can use with the Asp.netboilerplate SPA app ? I can use Angular Grid for some scenarios.But on the other use cases where I need to use some advance reporting tool like crystal report.Could you tell me which one is suitable for it with the AngularJs ? Thanks in advance.

Hi Halil,

OK sure. Thanks a lot.You too have a Great week ahead ! :)

Hi Halil,

Thanks for the reply.Me too think this is due to lazy loading issue.Is there any way to use eager loading with below mentioned query ? Thanks in advance.

var ownerDetail = await _ownerDetailRepository.FirstOrDefaultAsync(p => p.Id == input.OwnerDetail.Id);

Note : I know how to do it in general.But I would like to know how to it with ABP ?

Eager loading sample :

var blog1 = context.Blogs 
                        .Where(b => b.Name == "ADO.NET Blog") 
                        .Include(b => b.Posts) 
                        .FirstOrDefault();
public async Task<int> CreateOwnerDetailAsync(CreateOrEditOwnerDetailInput input)
        {
            var ownerDetail = input.OwnerDetail.MapTo<OwnerDetail>();
             var ownerDetailId = await _ownerDetailRepository.InsertAndGetIdAsync(ownerDetail);
            return ownerDetailId;
        }
public async Task<int?> EditOwnerDetailAsync(CreateOrEditOwnerDetailInput input)
        {
            var ownerDetail = await _ownerDetailRepository.FirstOrDefaultAsync(p => p.Id == input.OwnerDetail.Id);
            input.OwnerDetail.MapTo(ownerDetail);
            await _ownerDetailRepository.UpdateAsync(ownerDetail);
            return input.OwnerDetail.Id;

        }
public class CreateOrEditOwnerDetailInput : IInputDto
    {
        [Required]
        public OwnerDetailEditDto OwnerDetail { get; set; }
    }
[AutoMap(typeof(OwnerDetail))]
    public class OwnerDetailEditDto
    {
        public const int MaxLength = 50;
      
        public int? Id { get; set; }

        [Required]
        [MaxLength(MaxLength)]
        public string LastName { get; set; }
    
        [Required]
        public OwnerContactDetailDto ContactDetail { get; set; }
      
        [Required]
        public AdditionalAddressDto AdditionalAddress { get; set; }
      
    }
[Table("IpOwnerDetails")]
    public class OwnerDetail : FullAuditedEntity
    {
        public const int MaxLength = 50;
       
        [Required]
        [MaxLength(MaxLength)]
        public virtual string LastName { get; set; }

        [ForeignKey("AdditionalAddressId")]
        public virtual AdditionalAddress AdditionalAddress { get; set; }
        public virtual int AdditionalAddressId { get; set; }

        [ForeignKey("ContactDetailId")]
        public virtual ContactDetail ContactDetail { get; set; }
        public virtual int ContactDetailId { get; set; }


    }
public class OwnerContactDetailDto : FullAuditedEntityDto
    {
        public const int NumberMaxLength = 20;

        [Required]
        [MaxLength(NumberMaxLength)]
        public string MainPhoneNumber { get; set; }

        [MaxLength(NumberMaxLength)]
        public string CellPhoneNumber { get; set; }


    }
public class AdditionalAddressDto : FullAuditedEntityDto
    {
        public const int MaxLength = 50;

        [Required]
        [MaxLength(MaxLength)]
        public string StreetNumber { get; set; }

        [Required]
        [MaxLength(MaxLength)]
        public string StreetName { get; set; }

       }

Custom mapping :

private static void CreateMappingsInternal()
        {
           
            Mapper.CreateMap<AdditionalAddress, AdditionalAddressDto>()
              .ReverseMap()
              .ForMember(additionalAddress => additionalAddress.Id, options => options.Ignore());

            Mapper.CreateMap<ContactDetail, OwnerContactDetailDto>()
              .ReverseMap()
              .ForMember(contactDetail => contactDetail.Id, options => options.Ignore());


        }

Q : I can create an 'owner detail' by using above code.But when I try to use same "Save" button to edit the record it gives below exception.I have included more details on the attached image.Please see that too.Could you tell me why this is happening ? Thanks in advance.

Note : After this line " input.OwnerDetail.MapTo(ownerDetail);" inside the "EditOwnerDetailAsync()" method where "AdditionalAddress" and "ContactDetail " objects are changed it to "null".Could you tell me why ?

Note 2 : I have used custom mappings hence this error "System.InvalidOperationException: The property 'Id' is part of the object's key information and cannot be modified.".Now that error is not there.But it gives above mentioned error now.

Image : [http://imgur.com/a/GRdw6])

The strange thing here is when I bring the debug pointer back to the " input.OwnerDetail.MapTo(ownerDetail);" line (2nd time) then it fills data for the "AdditionalAddress" and "ContactDetail " objects.How can It be happend ? Please tell me :?:

Exception :

ERROR 2015-11-19 20:58:22,258 [5    ] lers.Filters.AbpExceptionFilterAttribute - System.ArgumentNullException: Value cannot be null.
Parameter name: entity
   at System.Data.Entity.Utilities.Check.NotNull[T](T value, String parameterName)
   at System.Data.Entity.DbSet`1.Attach(TEntity entity)
   at Abp.EntityFramework.Repositories.EfRepositoryBase`3.AttachIfNot(TEntity entity)
   at Castle.Proxies.EfRepositoryBase`2Proxy_18.AttachIfNot_callback(AdditionalAddress entity)
   at Castle.Proxies.Invocations.EfRepositoryBase`3_AttachIfNot_28.InvokeMethodOnTarget()
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation)
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Castle.Proxies.EfRepositoryBase`2Proxy_18.AttachIfNot(AdditionalAddress entity)
   at Abp.EntityFramework.Repositories.EfRepositoryBase`3.UpdateAsync(TEntity entity)
   at Castle.Proxies.EfRepositoryBase`2Proxy_18.UpdateAsync_callback(AdditionalAddress entity)
   at Castle.Proxies.Invocations.EfRepositoryBase`3_UpdateAsync_28.InvokeMethodOnTarget()
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation)
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Castle.Proxies.EfRepositoryBase`2Proxy_18.UpdateAsync(AdditionalAddress entity)
   at Joshi.IP.OwnerDetails.OwnerDetailAppService.&lt;EditOwnerDetailAsync&gt;d__e.MoveNext() in d:\Freelance Work\Nipun-SPA\SPA\island\Joshi.IP.Application\OwnerDetails\OwnerDetailAppService.cs:line 65
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Joshi.IP.OwnerDetails.OwnerDetailAppService.<CreateOrEditOwnerDetailAsync>d__0.MoveNext() in d:\Freelance Work\Nipun-SPA\SPA\island\Joshi.IP.Application\OwnerDetails\OwnerDetailAppService.cs:line 34
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Abp.Threading.InternalAsyncHelper.&lt;AwaitTaskWithPostActionAndFinallyAndGetResult&gt;d__10`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Abp.Threading.InternalAsyncHelper.&lt;AwaitTaskWithFinallyAndGetResult&gt;d__c`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Threading.Tasks.TaskHelpersExtensions.&lt;CastToObject&gt;d__3`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Abp.Extensions.ExceptionExtensions.ReThrow(Exception exception)
   at Abp.WebApi.Controllers.Dynamic.Selectors.DynamicHttpActionDescriptor.<ExecuteAsync>b__0(Task`1 task)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Web.Http.Controllers.ApiControllerActionInvoker.&lt;InvokeActionAsyncCore&gt;d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Web.Http.Controllers.AuthenticationFilterResult.&lt;ExecuteAsync&gt;d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()

Hi Halil,

Thank you so much :)

The problem was on the "AddressDto" mapping.I have done as you said and now it's working.Thanks again :)

Mapper.CreateMap<Address, AddressDto>()
              .ReverseMap()
              .ForMember(address => address.Id, options => options.Ignore());

Hi Halil,

That url is not working ? Could you correct it ? Thank in advance.

Hi Halil,

Thanks for the reply. Actually the ids are the same. Please see the attached image. One thing I have to note that here that is, The relationship between the "Properties" and "Addresses" tables are 1 : 1 (I have mentioned it on the image also).Is that the issue here ? If so then how can I sort out this issue ?

If there is no other solution could you tell me how to do custom mapping as you mentioned above.Just a reference or simple example is more than enough. Thanks in advance.

Here is the imge url : <a class="postlink" href="http://imgur.com/a/cJdei">http://imgur.com/a/cJdei</a>

Address :

[Table("IpAddresses")]
    public class Address : FullAuditedEntity
    {
        public const int MaxLength = 50;

        [Key, ForeignKey("Property")]
        public override int Id { get; set; }

        [Required]
        [MaxLength(MaxLength)]
        public virtual string StreetNumber { get; set; }

        [Required]
        [MaxLength(MaxLength)]
        public virtual string StreetName { get; set; }

        [ForeignKey("CityId")]
        public virtual City City { get; set; }
        public virtual int CityId { get; set; }

        [ForeignKey("StateId")]
        public virtual State State { get; set; }
        public virtual int StateId { get; set; }

        public virtual Property Property { get; set; }
    }
Showing 171 to 180 of 187 entries