Base solution for your next web application

Activities of "sampath"

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,

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();

Hi Halil,

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

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, 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>

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 ! :)

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])

Here is the Solution : cheers :)

Web\App\common\views\layout\sidebar.cshtml

<ul class="sub-menu" ng-if="menuItem.items.length">
                <li ui-sref-active="active" ng-repeat="childMenuItem in menuItem.items">

                    <a ui-sref="{{childMenuItem.url}}" ng-if="!childMenuItem.items.length">
                        <i class="{{childMenuItem.icon}}"></i>
                        <span class="title">{{childMenuItem.displayName}}</span>
                    </a>

                    <a href="javascript:;" class="auto" ng-if="childMenuItem.items.length">
                        <i class="{{childMenuItem.icon}}"></i>
                        <span class="title">{{childMenuItem.displayName}}</span>
                        <span class="arrow "></span>
                    </a>

                    <ul class="sub-menu" ng-if="childMenuItem.items.length">
                        <li ui-sref-active="active" ng-repeat="childMenuItem2 in childMenuItem.items">
                            <a ui-sref="{{childMenuItem2.url}}">
                                <span><i class="sub-menu-icon {{childMenuItem2.icon}}"></i> {{childMenuItem2.displayName}}</span>
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>

I would like to add more to this question. ;)

  1. At the time when ABP will have ASP.net 5 version,can we upgrade our existing apps into that version without any breaking changes ?

  2. Now Angular 2 Beta has been released.So When ABP will have that version ?

  3. Will we have issues when upgrade our existing apps into Angular 2 ?

Thanks in advance.

Hi Halil, Awesome ! Thanks a lot for the clarification :)

Showing 11 to 20 of 187 entries