Base solution for your next web application

Activities of "shimulcse"

Hi, I am using ASP.NET Core & Angular v4.0.0 with .NET Core 1.1 framework

I have an API named CreateCountry as like below

public async Task CreateCountry(CreateCountryInput input)
        {
            var country = input.MapTo<Country>();            
            await _CountryRepository.InsertAsync(country);
        }

Test API for CreateCountry as like below

[Fact]
        public async Task Should_Create_New_Country()
        {
            //Arrange

            //Act
            var input = new CreateCountryInput
            {
                CountryCode = "ARG",
                CountryName = "ARGENTINA"                
            };
            await _CountryAppService.CreateCountry(input);

            //Assert
            var allCountries = _CountryRepository.GetAllListAsync();
            allCountries.ShouldNotBeNull();
            var newlyInsertCountry = _CountryRepository.GetAllList().FirstOrDefault(t => t.CountryCode == "ARG");
            newlyInsertCountry.CountryName.ShouldBe("ARGENTINA");
        }

When checking the Test getting an error as below <span style="color:#BF0000">System.InvalidOperationException : Mapper not initialized. Call Initialize with appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance.</span>

Am I missing something to add?

Kindly Suggest.

Thanks Shimul

Using ObjectMapper problem is solved. Thanks.

Observed that some of your implemented tests API failed. What's are the reason?

Hi, Total 14 Test Failed

I have given some of the tests failed details.

<span style="color:#FF0000">Test Name: SAPL.SODMS.Tests.Authorization.Roles.RoleAppService_Tests.Should_Get_Roles_For_Host</span>

Test FullName:	SAPL.SODMS.Tests.Authorization.Roles.RoleAppService_Tests.Should_Get_Roles_For_Host (6ed7f976b875de0e042029be6634ecda6c90887e)
Test Source:	D:\Workarea\Projects\SAPL\SODMS\SODMSBackend\test\SAPL.SODMS.Tests\Authorization\Roles\RoleAppService_Tests.cs : line 20
Test Outcome:	Failed
Test Duration:	0:00:11.785

Result StackTrace:	
at Shouldly.ShouldlyCoreExtensions.AssertAwesomely[T](T actual, Func`2 specifiedConstraint, Object originalActual, Object originalExpected, Func`1 customMessage, String shouldlyMethod)
   at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected, Func`1 customMessage)
   at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected)
   at SAPL.SODMS.Tests.Authorization.Roles.RoleAppService_Tests.&lt;Should_Get_Roles_For_Host&gt;d__2.MoveNext() in D:\Workarea\Projects\SAPL\SODMS\SODMSBackend\test\SAPL.SODMS.Tests\Authorization\Roles\RoleAppService_Tests.cs:line 27
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Result Message:	Shouldly.ShouldAssertException : 2
    should be
1
    but was not

Test Name: SAPL.SODMS.Tests.Authorization.Users.UserAppService_Create_Tests.Should_Create_User_For_Host

Test FullName:	SAPL.SODMS.Tests.Authorization.Users.UserAppService_Create_Tests.Should_Create_User_For_Host (45c9dd1141158b61edde4f100c61a6981a8f9162)
Test Source:	D:\Workarea\Projects\SAPL\SODMS\SODMSBackend\test\SAPL.SODMS.Tests\Authorization\Users\UserAppService_Create_Tests.cs : line 18
Test Outcome:	Failed
Test Duration:	0:00:06.713

Result StackTrace:	
at Shouldly.ShouldlyCoreExtensions.AssertAwesomely[T](T actual, Func`2 specifiedConstraint, Object originalActual, Object originalExpected, Func`1 customMessage, String shouldlyMethod)
   at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected, Func`1 customMessage)
   at Shouldly.ShouldBeTestExtensions.ShouldBe[T](T actual, T expected)
   at SAPL.SODMS.Tests.Authorization.Users.UserAppService_Create_Tests.<>c__DisplayClass3_0.<<CreateUserAndTestAsync>b__0>d.MoveNext() in D:\Workarea\Projects\SAPL\SODMS\SODMSBackend\test\SAPL.SODMS.Tests\Authorization\Users\UserAppService_Create_Tests.cs:line 86
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at SAPL.SODMS.Tests.AppTestBase.<UsingDbContextAsync>d__8.MoveNext() in D:\Workarea\Projects\SAPL\SODMS\SODMSBackend\test\SAPL.SODMS.Tests\AppTestBase.cs:line 108
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at SAPL.SODMS.Tests.Authorization.Users.UserAppService_Create_Tests.<CreateUserAndTestAsync>d__3.MoveNext() in D:\Workarea\Projects\SAPL\SODMS\SODMSBackend\test\SAPL.SODMS.Tests\Authorization\Users\UserAppService_Create_Tests.cs:line 78
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at SAPL.SODMS.Tests.Authorization.Users.UserAppService_Create_Tests.<Should_Create_User_For_Host>d__0.MoveNext() in D:\Workarea\Projects\SAPL\SODMS\SODMSBackend\test\SAPL.SODMS.Tests\Authorization\Users\UserAppService_Create_Tests.cs:line 21
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Result Message:	Shouldly.ShouldAssertException : 1
    should be
null
    but was not

<span style="color:#FF0000">Test Name: SAPL.SODMS.Tests.Authorization.Users.UserAppService_Link_Tests.Should_Link_User_To_Already_Linked_User</span>

Test FullName:	SAPL.SODMS.Tests.Authorization.Users.UserAppService_Link_Tests.Should_Link_User_To_Already_Linked_User (b46f80720c662a2e585824bbc3e064d058cd927e)
Test Source:	D:\Workarea\Projects\SAPL\SODMS\SODMSBackend\test\SAPL.SODMS.Tests\Authorization\Users\UserAppService_Link_Tests.cs : line 74
Test Outcome:	Failed
Test Duration:	0:00:04.466

Result StackTrace:	
at SAPL.SODMS.Authorization.Users.UserLinkAppService.<LinkToUser>d__6.MoveNext() in D:\Workarea\Projects\SAPL\SODMS\SODMSBackend\src\SAPL.SODMS.Application\Authorization\Users\UserLinkAppService.cs:line 51
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinally>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithFinally>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at SAPL.SODMS.Tests.Authorization.Users.UserAppService_Link_Tests.<Should_Link_User_To_Already_Linked_User>d__9.MoveNext() in D:\Workarea\Projects\SAPL\SODMS\SODMSBackend\test\SAPL.SODMS.Tests\Authorization\Users\UserAppService_Link_Tests.cs:line 91
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Result Message:	Abp.UI.UserFriendlyException : Login failed!

Hi,

Yes, I have disabled Multitenancy and I am using ASPNETZERO version v4.0.0 (latest)

Thanks Shimul

Hi, I am using Visual Studio TEST EXPLORERS (Version 2017)

To disable Multitenancy I commented code from below file SAPL.SODMS.Core\SODMSCoreModule.cs

//Enable this line to create a multi-tenant application.
//Configuration.MultiTenancy.IsEnabled = SODMSConsts.MultiTenancyEnabled;

Do I need to change anything else to skip those tests?

Thanks Shimul Dey

Problem Solved.

Thanks

Hi, I have two entity Country & CountryPort

A country will have one or more CountryPort.

Exactly did same for the parent-child relationship as per your suggested documents. ( [https://www.aspnetzero.com/Documents/Developing-Step-By-Step-Angular#changing-getpeople-method]))

Without adding Include extension method to the query I am not getting CountryPort data (showing NULL) within Country.

var countries = _CountryRepository.GetAll().Include(c=> c.CountryPorts);

Without adding Include I am getting NULL in countries.CountryPorts

Also, didn't find any option to get CountryPorts for single Country data

var myCountry = _CountryRepository.Get(input.Id);

Will you please suggest.

Thanks Shimul Dey

I want to change the default Metronic theme to "Admin 3".

Is there any document which will help me to do that?

I am using ASP.NET CORE & Angular (v4.1.4) with .NET Core 1.1 framework.

Download theme (Version: metronic_v4.7) from your provided GitHub link.

Hi, Found problems that related to SoftDelete in PARENT/CHILD relationships.

var countries = _CountryRepository.GetAll().Include(c=> c.CountryPorts);

Problem#1: .Include(c=> c.CountryPorts) returning deleted (SoftDelete IsDeleted = 1) CountryPorts data also.

Problem#2: When deleting (SoftDelete) any Parent Data, system not restricting when there are some Child data with the Id of the parent data.

I used this for getting SqlConnection to execute StoredProcedure.

private readonly IConfigurationRoot _Configuration;

        public CargoReportAppService(ICargoHeldupLogRepository cargoHeldupLogRepository,
            ICargoReceivingInfoDetailRepository cargoReceivingInfoDetailRepository)
        {
            _CargoHeldupLogRepository = cargoHeldupLogRepository;
            _CargoReceivingInfoDetailRepository = cargoReceivingInfoDetailRepository;
            _Configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder(), addUserSecrets: true);
        }
using (var dbConnection = new SqlConnection(configuration.GetConnectionString(SODMSConsts.ConnectionStringName)))
                {
                    await dbConnection.OpenAsync();
                    cargoReceivingData = await dbConnection.QueryAsync<GetCargoReceivingReportOutput>("CargoReceivingReport",
                                        new
                                        {
                                            FromDate = input.FromDate.Date,
                                            ToDate = input.ToDate.Date,
                                            AccountId = (input.AccountId == 0 || input.AccountId == null) ? null : input.AccountId,
                                            DepotUnitId = (input.DepotUnitId == 0 || input.DepotUnitId == null) ? null : input.DepotUnitId
                                        },
                                        commandType: CommandType.StoredProcedure);

                }

This is working fine in locally but getting error in production. Kindly suggest me other way to do that.

Showing 1 to 10 of 17 entries