Beispiel #1
0
        public async Task <IActionResult> Next(Guid commissionStatementId)
        {
            var scope = AuthenticationService.GetScope(User);

            var error = await CommissionErrorService.GetNextError(scope, commissionStatementId);

            if (error == null)
            {
                return(NotFound());
            }

            return(Ok(error));
        }
        public async Task GetNextError()
        {
            var options = TestHelper.GetDbContext("GetNextError");

            var user1     = TestHelper.InsertUserDetailed(options);
            var statement = TestHelper.InsertCommissionStatement(options, user1.Organisation);

            var user2      = TestHelper.InsertUserDetailed(options);
            var statement2 = TestHelper.InsertCommissionStatement(options, user2.Organisation);

            var error1 = new CommissionErrorEntity
            {
                CommissionStatementId = statement.Id,
                PolicyId         = Guid.NewGuid(),
                ClientId         = Guid.NewGuid(),
                CommissionTypeId = Guid.NewGuid(),
                Data             = new ImportCommission()
            };

            var error2 = new CommissionErrorEntity
            {
                CommissionStatementId = statement2.Id,
                PolicyId         = Guid.NewGuid(),
                ClientId         = Guid.NewGuid(),
                CommissionTypeId = Guid.NewGuid(),
                Data             = new ImportCommission()
            };

            using (var context = new DataContext(options))
            {
                context.CommissionError.Add(error2);
                context.CommissionError.Add(error1);
                context.SaveChanges();

                var service = new CommissionErrorService(context, null, null, null, null, null, null);

                //When
                var scope  = TestHelper.GetScopeOptions(user1);
                var actual = await service.GetNextError(scope, statement.Id);

                //Then
                Assert.Equal(error1.CommissionStatementId, actual.CommissionStatementId);
                Assert.Equal(error1.PolicyId, actual.PolicyId);
                Assert.Equal(error1.ClientId, actual.ClientId);
                Assert.Equal(error1.CommissionTypeId, actual.CommissionTypeId);
                Assert.Equal(error1.Data, actual.Data);
            }
        }