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

            var error = await CommissionErrorService.GetError(scope, commissionErrorId);

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

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

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

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

            var error2 = new CommissionErrorEntity
            {
                Id = Guid.NewGuid(),
                CommissionStatementId = statement.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.GetError(scope, error1.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);
            }
        }