Base solution for your next web application

Activities of "andis"

Is there anyway to automate the creation process of AppPermissions? Is there any particular reason to put AppAuthorizationProvider in .Core level? I intended to create AppPermissions for all Application Service, but I cannot use reflection as the AppAuthorizationProvider is in .Core level while all services are in .Application level

I ran all unit test from aspnetzero project. Why always got some unit tests failed. Failed Test are randomly occur and if I run again those failed tests, they will pass.

Result Message: System.Data.Entity.Infrastructure.CommitFailedException : An error was reported while committing a database transaction but it could not be determined whether the transaction succeeded or failed on the database server. See the inner exception and <a class="postlink" href="http://go.microsoft.com/fwlink/?LinkId=313468">http://go.microsoft.com/fwlink/?LinkId=313468</a> for more information. ---- System.Transactions.TransactionAbortedException : The transaction has aborted. -------- System.TimeoutException : Transaction Timeout

Am I allowed to access other domain service method in a domain service's method?

......
{
    public class LookUpTableService_Tests : AppTestBase
    {
        private readonly ILookUpTableService _lookUpTableService;
        private readonly IRepository<LookUpTable, Guid> _repositoryLookUpTable;
        private readonly IRepository<LookUpTableLine, Guid> _repositoryLookUpTableLine;
        public LookUpTableService_Tests()
        {
            _lookUpTableService = Resolve<ILookUpTableService>();
            _repositoryLookUpTable = Resolve<IRepository<LookUpTable, Guid>>();
            _repositoryLookUpTableLine = Resolve<IRepository<LookUpTableLine, Guid>>();
        }
        [Fact]
        public async Task Test_GetValue()
        {
            LoginAsDefaultTenantAdmin();
            await UsingDbContext(async context =>
            {
                LookUpTable lookUpTable = new LookUpTable();
                lookUpTable.Name = "1";
                lookUpTable.Active = true;
                    await _repositoryLookUpTable.InsertAsync(lookUpTable);
                    LookUpTableLine line = new LookUpTableLine();
                    line.LookUpTableId = lookUpTable.Id;
                    line.LookUpValue = 1;
                    line.Value = 10;
                    line.Description = 1.ToString();
                    await _repositoryLookUpTableLine.InsertAsync(line);
                    line = new LookUpTableLine();
                    line.LookUpTableId = lookUpTable.Id;
                    line.LookUpValue = 2;
                    line.Value = 20;
                    line.Description = 2.ToString();
                    await _repositoryLookUpTableLine.InsertAsync(line);
                    line = new LookUpTableLine();
                    line.LookUpTableId = lookUpTable.Id;
                    line.LookUpValue = 3;
                    line.Value = 30;
                    line.Description = 3.ToString();
                    await _repositoryLookUpTableLine.InsertAsync(line);
                    line = new LookUpTableLine();
                    line.LookUpTableId = lookUpTable.Id;
                    line.LookUpValue = 4;
                    line.Value = 40;
                    line.Description = 4.ToString();
                    await _repositoryLookUpTableLine.InsertAsync(line);
                    line = new LookUpTableLine();
                    line.LookUpTableId = lookUpTable.Id;
                    line.LookUpValue = 5;
                    line.Value = 50;
                    line.Description = 5.ToString();
                    await _repositoryLookUpTableLine.InsertAsync(line);
                    lookUpTable = new LookUpTable();
                    lookUpTable.Name = "2";
                    lookUpTable.Active = true;
                    await _repositoryLookUpTable.InsertAsync(lookUpTable);
                    line = new LookUpTableLine();
                    line.LookUpTableId = lookUpTable.Id;
                    line.LookUpValue = 6;
                    line.Value = 60;
                    line.Description = 6.ToString();
                    await _repositoryLookUpTableLine.InsertAsync(line);
                    line = new LookUpTableLine();
                    line.LookUpTableId = lookUpTable.Id;
                    line.LookUpValue = 7;
                    line.Value = 70;
                    line.Description = 7.ToString();
                    await _repositoryLookUpTableLine.InsertAsync(line);
                    line = new LookUpTableLine();
                    line.LookUpTableId = lookUpTable.Id;
                    line.LookUpValue = 8;
                    line.Value = 80;
                    line.Description = 8.ToString();
                    await _repositoryLookUpTableLine.InsertAsync(line);
                    line = new LookUpTableLine();
                    line.LookUpTableId = lookUpTable.Id;
                    line.LookUpValue = 9;
                    line.Value = 90;
                    line.Description = 9.ToString();
                    await _repositoryLookUpTableLine.InsertAsync(line);
                    line = new LookUpTableLine();
                    line.LookUpTableId = lookUpTable.Id;
                    line.LookUpValue = 10;
                    line.Value = 100;
                    line.Description = 10.ToString();
                    await _repositoryLookUpTableLine.InsertAsync(line);
                try
                {
                    lookUpTable = _repositoryLookUpTable.FirstOrDefault(m => m.Name == "1");
                    Assert.Equal(4, _lookUpTableService.GetValue(lookUpTable, (decimal)4.5)); //Error on GetValue
                    lookUpTable = _repositoryLookUpTable.FirstOrDefault(m => m.Name == "2");
                    Assert.Equal(0, _lookUpTableService.GetValue(lookUpTable, (decimal)4.5));
                    Assert.Equal(10, _lookUpTableService.GetValue(lookUpTable, 14));
                }
                catch(Exception ex)
                {
                    throw ex;
                }
            });
        }
    }
}

GetValue code

public decimal GetValue(LookUpTable lookUpTable, decimal lookUpValue)
        {
            LookUpTableLine line = RepositoryLookUpTableLine.GetAll().Where(m => m.LookUpTable == lookUpTable && m.LookUpValue < lookUpValue).OrderByDescending(m => m.LookUpValue).FirstOrDefault();
            if (line == null)
                return 0;
            return line.Value;
        }

Error Message: The operation cannot be completed because the DbContext has been disposed. Stack Trace: at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source) at Nascence.HaermesCLX.DomainServices.Class.LookUpTableService.GetValue(LookUpTable lookUpTable, Decimal lookUpValue) in C:\Development\CLxCoreApp\Nascence.HaermesCLX.Core\DomainServices\Class\LookUpTableService.cs:line 29 at Nascence.HaermesCLX.Tests.DomainServices.LookUpTableService_Tests.<<Test_GetValue>b__4_0>d.MoveNext() in C:\Development\CLxCoreApp\Tests\Nascence.HaermesCLX.Tests\DomainServices\LookUpTableService_Tests.cs:line 101

Is there anything wrong with my code? why it keep getting this error? i tried to change it to non-awaitable.. still got same error

Do you mind to explain why my unit test need a transactional? why lack of transactional will cause me this error?

Can application service receive file type input?

We want to move our background job process to windows service. In web application, we will let user able to enqueue a job, but all the execution process will move to a windows service. What modules will i need and how to initialize them in windows service?

From EntityFramework side, after we insert a POCO, all navigational properties are still null. I found some solutions mentioned that i need to detach and find again to refresh the object or using DbSet.Create to create my entity instead using POCO constructor. But currently I am unable to access either DbContext or DbSet from Repository. How to reload the instance in aspboilerplate? or how to access DbContext or DbSet?

Create, SaveChanges and GetId() step is exactly what i tested before submit this ticket. But it seems EF has cached the created object, that's why in solution suggest me to detach it first and find it again..

Ok, I'll try your CustomRepository Solution

When resolving dependency, is IRepository<Entity, IdType) also inherit from EfRepositoryBase? if yes, then i can just cast it to this Type and get Context property instead re-implementing whole class

Showing 1 to 10 of 17 entries