Base solution for your next web application

Activities of "manojreddy"

I have defined a method defined in AppService file, Signature of method is

public PagedResultDto<FetchData> GetSearchData(FetchDataInput searchInput)

. I'm calling this method from Angular code, but

service-proxoes.ts

file has generated method in which I need to pass all the parameters one by one.

public class FetchDataInput: PagedAndSortedInputDto, IShouldNormalize
{
    public int DataLevel { get; set; }
    public int DataType { get; set; }
    public string DataCode { get; set; }
    public string DescLong { get; set; }
    public string LanguageCode { get; set; }
    public string DataParent { get; set; }

    public void Normalize()
    {
        if (string.IsNullOrEmpty(Sorting))
        {
            Sorting = "DataCode";
        }
    }

}

Service-Proxies.ts file:

getSearchData(dataLevel: number, dataType: number, dataCode: string, descLong: string, languageCode: string, dataParent: string, sorting: string, maxResultCount: number, skipCount: number): Observable<PagedResultDtoOfFetchData> {

So I have to call the getSearchData method by the following way.

this._dataService.getSearchData(AppConsts.dataLevelType, undefined, undefined,
        undefined, this.currentLanguage.name, undefined, undefined, undefined, undefined).subscribe((result) => {
           //result.items;
        });

So I have to pass all the parameters, but if let's say there are 100 parameters, it will be error prone and not good programming style. So it has to take a class object that's it. So is there any way to do the this?

I have a table which has the code as primary key instead of Id, When I call DeleteAsync method I get the exception Message = "Cannot update identity column 'Id'.".

[Table("Test")]

public class Test: FullAuditedEntity<int>

{

[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
new public int Id { get; set; }
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public virtual int Code { get; set; }

public async Task DeleteTest(int code)
    {


        try
        {
            await _supplierRepository.DeleteAsync(p => p.Code== code);
        }
        catch (Exception ex)
        {

        }
    }

But If I remove Id column from the table, it works fine. I want both Id column and Code column as PK.

I have gone through some posts, there it is mentioned that primary key has to be Id. Why Abp framework enforces to use only ID as primary key, there has to be some strong reason behind it.

I have a table which has the Id as primary key, I want to have a composite unique key on Code and Value column. I'm trying in this way.

[Table("Test")]

public class Test: FullAuditedEntity

{


[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public virtual int Code { get; set; }

[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public virtual int Value { get; set; }

But it's making the composite primary key not unique key.

I have a page in that I have a table. There is one column named "Actions".

Action-menu is shown with Edit and Delete, once the user clicks on the action-column in any row. I redirect to another html page once the user clicks on edit.

Everything is working fine. But the menu does not disappear after redirecting to another page. If I go back and again click on a action-column, a new menu with edit and delete appears.

<p-dataTable #dataTable>
    <p-column field="" header="{{l('Actions')}}" [sortable]="false" [style]="{'width':'25px'}">
        <ng-template let-record="rowData" pTemplate="body">
            <div class="btn-group dropdown" normalizePosition>
                <button class="dropdown-toggle btn btn-xs btn-primary blue"
                        data-toggle="dropdown"
                        aria-haspopup="true"
                        aria-expanded="false">
                    <i class="fa fa-cog"></i>
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    <li>
                        <a (click)="onEditClick(record, $event)">{{ l('Edit') }}</a>
                    </li>
                    <li>
                        <a (click)="onDeleteClick(record, $event)">{{ l('Delete') }}</a>
                    </li>
                </ul>
            </div>
        </ng-template>
    </p-column>
</p-dataTable>

onEditClick(selectedValue: any): void {
   this.router.navigate(['/app/xyz/pqr', data.id]);
}

Hi,

Thanks for your reply.

I'm not able to get the entity from DB as well, please share the code.

Hi,

Thanks for reply.

Do we have library like nswag which generates proxy file as per my requirement?.

Thanks

I have a calendar control, I want to set some value to it, but I get the following error on the below line and value also does not get set.

this.data.dateIn = this.selecteddata.dateIn; //both are moment type
<p-calendar [(ngModel)]="data.dateIn" [showIcon]="true" name="dateInCalendar"   
             required #dateInCalendar="ngModel">
</p-calendar>

Error:

ERROR Error: Uncaught (in promise): TypeError: date.getMonth is not a function TypeError: date.getMonth is not a function at Calendar.webpackJsonp.../../../../primeng/components/calendar/calendar.js.Calendar.formatDate (calendar.js:649) at Calendar.webpackJsonp.../../../../primeng/components/calendar/calendar.js.Calendar.updateInputfield (calendar.js:252) at Calendar.webpackJsonp.../../../../primeng/components/calendar/calendar.js.Calendar.writeValue (calendar.js:595) at forms.es5.js:1779 at forms.es5.js:2965 at Array.forEach () at FormControl.webpackJsonp.../../../forms/@angular/forms.es5.js.FormControl.setValue (forms.es5.js:2965) at forms.es5.js:4367 at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:365) at Object.onInvoke (core.es5.js:3890) at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:364) at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run (zone.js:125) at zone.js:758 at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:398) at Object.onInvokeTask (core.es5.js:3881) at Calendar.webpackJsonp.../../../../primeng/components/calendar/calendar.js.Calendar.formatDate (calendar.js:649) at Calendar.webpackJsonp.../../../../primeng/components/calendar/calendar.js.Calendar.updateInputfield (calendar.js:252) at Calendar.webpackJsonp.../../../../primeng/components/calendar/calendar.js.Calendar.writeValue (calendar.js:595) at forms.es5.js:1779 at forms.es5.js:2965 at Array.forEach () at FormControl.webpackJsonp.../../../forms/@angular/forms.es5.js.FormControl.setValue (forms.es5.js:2965) at forms.es5.js:4367 at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:365) at Object.onInvoke (core.es5.js:3890) at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:364) at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run (zone.js:125) at zone.js:758 at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:398) at Object.onInvokeTask (core.es5.js:3881) at resolvePromise (zone.js:710) [angular] at :4200/polyfills.bundle.js:7469:17 [angular] at Object.onInvokeTask (core.es5.js:3881) [angular] at drainMicroTaskQueue (zone.js:591) [] at XMLHttpRequest.ZoneTask.invoke (zone.js:464) []

How to solve Can't create component as it has dependencies to be satisfied in ASP.NET Boilerplate?

Getting error while running test. How to solve?

public class TestAppService : TestAppServiceBase, ITestAppService
    {
        private readonly ITestRepository _testRepository;
        public TestAppService(ITestRepository testRepository)
        {
            _testRepository = testRepository;
        }

public class TestAppService_Test : TestAppServiceTestBase
    {
        private readonly ITestAppService _testAppService;

    public TestAppService_Test()
    {
        _testAppService = Resolve<ITestAppService>();
    }


Test Name:  

ABC.XYZ.Tests.PQR.TestAppService_Test.Should_Create_Test_With_Valid_Arguments
Test FullName:  ABC.XYZ.Tests.PQR.TestAppService_Test.Should_Create_Test_With_Valid_Arguments (20f54c54e5d9f077f4cb38b988ecb8e63e07d190)
Test Source:    C:\Users\viveknuna\source\repos\XYZ\aspnet-core\test\ABC.XYZ.Tests\PQR\TestAppService_test.cs : line 25
Test Outcome:   Failed
Test Duration:  0:00:00.001

Result StackTrace:  
at Castle.MicroKernel.Handlers.DefaultHandler.AssertNotWaitingForDependency()
   at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
   at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
   at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy)
   at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy)
   at Castle.Windsor.WindsorContainer.Resolve[T]()
   at ABC.XYZ.Tests.PQR.TestAppServiceTestBase..ctor() in C:\Users\viveknuna\source\repos\XYZ\aspnet-core\test\ABC.XYZ.Tests\PQR\TestAppServiceTestBase.cs:line 14
   at ABC.XYZ.Tests.PQR.TestAppService_Test..ctor() in C:\Users\viveknuna\source\repos\XYZ\aspnet-core\test\ABC.XYZ.Tests\PQR\TestAppService_test.cs:line 17
Result Message: 
Castle.MicroKernel.Handlers.HandlerException : Can't create component 'ABC.XYZ.Business.Services.PQR.TestAppService' as it has dependencies to be satisfied.

'ABC.XYZ.Business.Services.PQR.TestAppService' is waiting for the following dependencies:
- Service 'ABC.XYZ.Business.Repositories.Interfaces.ITestRepository' which was not registered.

Please find the code below.

public interface ITestRepository : IRepository<Test, int>
    {
        PagedResultDto<FetchTest> GetSearchTest(FetchTestInput searchInput);

        Task<int> CreateTest(TestDetailsDTO input);

        Task UpdateTest(TestDetailsDTO input);

        TestDetailsDTO GetTestDetailsforEdit(EntityDto input);

        Task DeleteTest(EntityDto input);

        ListResultDto<FetchTest> GetTestList(string input);

    }
public class TestRepository : TestRepositoryBase<Test, int>, ITestRepository
    {
        private readonly IActiveTransactionProvider _transactionProvider;
        public TestRepository(IDbContextProvider<TestDbContext> dbContextProvider)
            : base(dbContextProvider)
        {
        }

        public TestRepository(IDbContextProvider<TestDbContext> dbContextProvider,
            IActiveTransactionProvider transactionProvider, IObjectMapper objectMapper)
        : base(dbContextProvider)
        {
            _transactionProvider = transactionProvider;
            ObjectMapper = objectMapper;
        }

        public async Task<int> CreateTest(TestDetailsDTO input)
        {

            int TestId = await InsertAndGetIdAsync(ObjectMapper.Map<Test>(input));

            return TestId;

        }

        public async Task DeleteTest(EntityDto input)
        {
            await DeleteAsync(input.Id);
        }

        public PagedResultDto<FetchTest> GetSearchTest(FetchTestInput searchInput)
        {
            var _Tests = GetAll()
                .Where(f => (!string.IsNullOrWhiteSpace(searchInput.TestCode) ? f.TestCode.Contains(searchInput.TestCode) : true) &&
                            (!string.IsNullOrWhiteSpace(searchInput.TestDesc) ? f.TestDesc.Contains(searchInput.TestDesc) : true));

            var _result = (from details in _Tests
                           select new FetchTest
                           {
                               Id = details.Id,
                               TestCode = details.TestCode,
                               TestDesc = details.TestDesc,
                               TestName = details.TestName,
                               AbcCode = details.AbcCode
                           });

            var TestCount = _result.Count();
            var Tests = ObjectMapper.Map<List<FetchTest>>(_result
            .OrderBy(searchInput.Sorting)
            .PageBy(searchInput)
            .ToList());

            return new PagedResultDto<FetchTest>(
                 TestCount,
                 Tests
                );
        }

        public TestDetailsDTO GetTestDetailsforEdit(EntityDto input)
        {
            var result = (from Test in GetAll()
                          where ((Test.Id == input.Id))

                          select new TestDetailsDTO
                          {
                              TestCode = Test.TestCode,
                              TestName = Test.TestName,
                              TestDesc = Test.TestDesc,
                              AbcCode = Test.AbcCode
                          });

            int count = result.Count();

            return ObjectMapper.Map<TestDetailsDTO>(result.FirstOrDefault());
        }

        public ListResultDto<FetchTest> GetTestList(string input)
        {
            var Tests = GetAll()
                             .Where(a => (a.Id.ToString().Equals(input) || a.TestCode.Contains(input) || a.TestDesc.Contains(input)));

            return new ListResultDto<FetchTest>(ObjectMapper.Map<List<FetchTest>>(Tests));
        }

        public async Task UpdateTest(TestDetailsDTO input)
        {
            var classobj = ObjectMapper.Map<Test>(input);
            await UpdateAsync(classobj);
        }
    }

@ismcagdas

Any update?

Showing 1 to 10 of 267 entries