Пример #1
0
        internal static IResult <SetLotAttributeParameters> ToParsedParameters(this ISetLotAttributeParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var lotKey = KeyParserHelper.ParseResult <ILotKey>(parameters.LotKey);

            if (!lotKey.Success)
            {
                return(lotKey.ConvertTo <SetLotAttributeParameters>());
            }

            var attributes = new Dictionary <AttributeNameKey, IAttributeValueParameters>();

            foreach (var attribute in parameters.Attributes)
            {
                var attributeNameResult = KeyParserHelper.ParseResult <IAttributeNameKey>(attribute.Key);
                if (!attributeNameResult.Success)
                {
                    return(attributeNameResult.ConvertTo <SetLotAttributeParameters>());
                }
                attributes.Add(new AttributeNameKey(attributeNameResult.ResultingObject), attribute.Value);
            }

            return(new SuccessResult <SetLotAttributeParameters>(new SetLotAttributeParameters
            {
                Parameters = parameters,
                LotKey = lotKey.ResultingObject.ToLotKey(),
                Attributes = attributes
            }));
        }
Пример #2
0
 public IResult <ILotStatInfoReturn> SetLotAttributes(ISetLotAttributeParameters parameters)
 {
     try
     {
         return(_lotServiceProvider.SetLotAttributes(parameters));
     }
     catch (Exception ex)
     {
         _exceptionLogger.LogException(ex);
         return(new FailureResult <ILotStatInfoReturn>(null, ex.Message));
     }
 }
Пример #3
0
            public void ParametersAreCorrectlyTranslatedToDto()
            {
                // Arrange
                ISetLotAttributeParameters actualParameters = null;

                MockLotService.Setup(m => m.SetLotAttributes(It.IsAny <ISetLotAttributeParameters>()))
                .Callback((ISetLotAttributeParameters p) => actualParameters = p)
                .Returns(new SuccessResult <ILotStatInfoReturn>());

                // Act
                LotsControler.Put(LotKey, _values);

                // Assert
                Assert.IsNotNull(actualParameters);
                Assert.AreEqual(LotKey, actualParameters.LotKey);
                Assert.AreEqual(((ISetLotAttributeParameters)_values).Attributes, actualParameters.Attributes);
            }
Пример #4
0
        public IResult <ILotStatInfoReturn> SetLotAttributes(ISetLotAttributeParameters parameters)
        {
            var parsedParameters = parameters.ToParsedParameters();

            if (!parsedParameters.Success)
            {
                return(parsedParameters.ConvertTo <ILotStatInfoReturn>());
            }

            var currentTimeStamp    = _timeStamper.CurrentTimeStamp;
            var setAttributesResult = new SetLotAttributesConductor(_lotUnitOfWork).Execute(currentTimeStamp, parsedParameters.ResultingObject);

            if (!setAttributesResult.Success)
            {
                return(setAttributesResult.ConvertTo <ILotStatInfoReturn>());
            }

            #region SetLotStatus to 'Accepted'

#warning Remove if/when 'OverrideOldContextLotAsCompleted' is removed. -RI 6/16/2014

            if (parameters.OverrideOldContextLotAsCompleted)
            {
                var setStatusResult = new SetLotStatusConductor(_lotUnitOfWork).Execute(currentTimeStamp, new SetLotStatusParameters
                {
                    LotKey     = parsedParameters.ResultingObject.LotKey,
                    Parameters = parsedParameters.ResultingObject
                }, true);
                if (!setStatusResult.Success)
                {
                    return(setStatusResult.ConvertTo <ILotStatInfoReturn>());
                }
            }

            #endregion

            _lotUnitOfWork.Commit();

            var syncParameters = new SynchronizeLotParameters
            {
                LotKey = parsedParameters.ResultingObject.LotKey,
                OverrideOldContextLotAsCompleted = parameters.OverrideOldContextLotAsCompleted
            };
            return(SyncParameters.Using(new SuccessResult <ILotStatInfoReturn>(new LotStatInfoReturn(syncParameters)), syncParameters));
        }