Exemplo n.º 1
0
        public void CanAddOecdCode()
        {
            var wasteCode = GetTestWasteCode(Guid.NewGuid(), CodeType.Oecd);

            notification.SetBaselOecdCode(WasteCodeInfo.CreateWasteCodeInfo(wasteCode));

            Assert.NotNull(notification.BaselOecdCode);
            Assert.Equal(CodeType.Oecd, notification.BaselOecdCode.WasteCode.CodeType);
        }
Exemplo n.º 2
0
        private async Task SetCode(SetBaselOecdCodeForNotification message, NotificationApplication notification)
        {
            var wasteCode = await context.WasteCodes.SingleAsync(wc => wc.Id == message.Code);

            if (wasteCode.CodeType != message.CodeType)
            {
                var errorMessage =
                    string.Format(
                        "Tried to set an invalid code of type {0} where the set for code type {1} was requested. For notification {2}.",
                        wasteCode.CodeType,
                        message.CodeType,
                        message.Id);

                throw new InvalidOperationException(errorMessage);
            }

            notification.SetBaselOecdCode(WasteCodeInfo.CreateWasteCodeInfo(wasteCode));

            ClearOldCodes(message, notification);
        }