Base solution for your next web application

Activities of "manojreddy"

Hi, I have some master data in DB which I need throughout my application. So What is the best way to define this data in the application? and Where should I define in the application so that every time applications starts I will initialize this master data in my application. And Where should I define the method which will fetch data from DB?

I'm thinking of having the dictionary in AppConsts.cs file in the Application project

Thanks for your reply, it works perfectly.

I'm not able to get the key (allowSwaggerToRunAPIs ) value from the app.config file in Startup.cs file. I want to make this as configurable.

<configuration>
  <appSettings>
    <add key="owin:AutomaticAppStartup" value="false"/>
    <add key="allowSwaggerToRunAPIs" value="true"/>
  </appSettings>
  <runtime>
      <gcServer enabled="true"/>
   </runtime>
</configuration>

I'm using [AbpAuthorize] with methods, so I'm not able to call methods from Swagger API. The reason is simple that user is not logged in, so Do we have any way to send login credentials from Swagger UI?

Or Do we have any way to have configurable [AbpAuthorize] based on some flag? So that for my development environment I can disable [AbpAuthorize] and in the live environment, I will enable [AbpAuthorize].

I'm using PrimeNG controls(datatable, dropdown) at many places in UI, But every time I stuck with some issues. There is no good documentation and support for on StackOverflow for PrimeNG, So Do we have any alternative for the same?

Please help me to solve the below issue, if possible at your end.

[https://stackoverflow.com/questions/47144652/custom-sorting-not-working-in-primeng-datatable]) [https://stackoverflow.com/questions/47145123/custom-content-dropdown-not-working-in-primeng]) [https://stackoverflow.com/questions/47144857/filterig-is-not-working-in-primeng-datatable])

If let's say I have a deleted a row, again create a row with same unique index attribute. Now If I again delete the record it will give an error. So How can We solve this issue?

I have a columns FlgStdTest which is DEFAULT ((1)) and datatype is bit. I'm trying to insert the record with FlgStdTest as true or false, but its value is always inserted as true.

public async Task<int> CreateTest(TestDetailsDTO input)
    {
        int testId = await InsertAndGetIdAsync(ObjectMapper.Map<TestMaster>(input));

        return testId;
    }

    [AutoMap(typeof(TestMaster))]
public class TestDetailsDTO : FullAuditedEntityDto
{
    public string Test { get; set; }
    public string TestDesc { get; set; }
    public bool FlgStdTest { get; set; }
    public bool FlgActive { get; set; }
}

Request:

{
  "testType": "abc",
  "testDesc": "xyz",
  "flgStdtest": false,
  "flgActive": false,
  "isDeleted": false,
  "deleterUserId": 0,
  "deletionTime": "2017-10-05T10:50:13.956Z",
  "lastModificationTime": "2017-10-05T10:50:13.956Z",
  "lastModifierUserId": 0,
  "creationTime": "2017-10-05T10:50:13.956Z",
  "creatorUserId": 0,
  "id": 0
}

Thanks a lot @aaron

@ismcagdas

Any update?

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

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.
Showing 251 to 260 of 267 entries