public IResult <string> UpdatePackSchedule(IUpdatePackScheduleParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var parametersResult = parameters.ToParsedParameters(); if (!parametersResult.Success) { return(parametersResult.ConvertTo <string>()); } var result = new UpdatePackScheduleCommand(_productionUnitOfWork).Execute(_timeStamper.CurrentTimeStamp, parametersResult.ResultingObject); if (!result.Success) { return(result.ConvertTo <string>()); } _productionUnitOfWork.Commit(); var packScheduleKey = result.ResultingObject.ToPackScheduleKey(); return(SyncParameters.Using(new SuccessResult <string>(packScheduleKey), packScheduleKey)); }
public new void SetUp() { MockPackScheduleService.Setup(m => m.UpdatePackSchedule(It.IsAny <IUpdatePackScheduleParameters>())) .Callback((IUpdatePackScheduleParameters valuesParam) => { _actualValues = valuesParam; }) .Returns(new SuccessResult <string>("newkey")); }
public IResult <string> UpdatePackSchedule(IUpdatePackScheduleParameters parameters) { try { var result = _productionServiceProvider.UpdatePackSchedule(parameters); return(result); } catch (Exception ex) { _exceptionLogger.LogException(ex); return(new FailureResult <string>(null, ex.GetInnermostException().Message)); } }
internal static IResult <UpdatePackScheduleCommandParameters> ToParsedParameters(this IUpdatePackScheduleParameters parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } var packScheduleKey = KeyParserHelper.ParseResult <IPackScheduleKey>(parameters.PackScheduleKey); if (!packScheduleKey.Success) { return(packScheduleKey.ConvertTo((UpdatePackScheduleCommandParameters)null)); } var workTypeKey = KeyParserHelper.ParseResult <IWorkTypeKey>(parameters.WorkTypeKey); if (!workTypeKey.Success) { return(workTypeKey.ConvertTo((UpdatePackScheduleCommandParameters)null)); } var chileProductKey = KeyParserHelper.ParseResult <IChileProductKey>(parameters.ChileProductKey); if (!chileProductKey.Success) { return(chileProductKey.ConvertTo((UpdatePackScheduleCommandParameters)null)); } var packagingProductKey = KeyParserHelper.ParseResult <IPackagingProductKey>(parameters.PackagingProductKey); if (!packagingProductKey.Success) { return(packagingProductKey.ConvertTo((UpdatePackScheduleCommandParameters)null)); } var productionLocationKey = KeyParserHelper.ParseResult <ILocationKey>(parameters.ProductionLineKey); if (!productionLocationKey.Success) { return(productionLocationKey.ConvertTo((UpdatePackScheduleCommandParameters)null)); } CustomerKey customerKey = null; if (!string.IsNullOrWhiteSpace(parameters.CustomerKey)) { var customerKeyResult = KeyParserHelper.ParseResult <ICustomerKey>(parameters.CustomerKey); if (!customerKeyResult.Success) { return(productionLocationKey.ConvertTo((UpdatePackScheduleCommandParameters)null)); } customerKey = new CustomerKey(customerKeyResult.ResultingObject); } return(new SuccessResult <UpdatePackScheduleCommandParameters>(new UpdatePackScheduleCommandParameters { Parameters = parameters, PackScheduleKey = new PackScheduleKey(packScheduleKey.ResultingObject), WorkTypeKey = new WorkTypeKey(workTypeKey.ResultingObject), ChileProductKey = new ChileProductKey(chileProductKey.ResultingObject), PackagingProductKey = new PackagingProductKey(packagingProductKey.ResultingObject), ProductionLocationKey = new LocationKey(productionLocationKey.ResultingObject), CustomerKey = customerKey })); }
internal static void AssertAsExpected(this IUpdatePackScheduleParameters parameters, PackSchedule packSchedule) { ((ICreatePackScheduleParameters)parameters).AssertAsExpected(packSchedule); }