public async Task <ActionResult> Copy(DerivativeMappingParameters parameters)
        {
            parameters.CopyToGateways = (IEnumerable <string>)TempData["CopyToGateways"];
            var derivativeMappingView = await GetModelFromParameters(parameters);

            if (derivativeMappingView.DerivativeMapping is EmptyFdpDerivativeMapping)
            {
                return(JsonGetFailure("DerivativeMapping does not exist"));
            }

            derivativeMappingView.DerivativeMapping = await DataContext.Vehicle.CopyFdpDerivativeMappingToDocument(FdpDerivativeMapping.FromParameters(parameters), parameters.TargetDocumentId.GetValueOrDefault());

            if (derivativeMappingView.DerivativeMapping is EmptyFdpDerivativeMapping)
            {
                return(JsonGetFailure(string.Format("DerivativeMapping '{0}' could not be copied", derivativeMappingView.DerivativeMapping.ImportDerivativeCode)));
            }

            return(JsonGetSuccess());
        }
        public async Task <ActionResult> Delete(DerivativeMappingParameters parameters)
        {
            var derivativeMappingView = await GetModelFromParameters(parameters);

            if (derivativeMappingView.DerivativeMapping is EmptyFdpDerivativeMapping)
            {
                return(JsonGetFailure("DerivativeMapping does not exist"));
            }

            derivativeMappingView.DerivativeMapping = await DataContext.Vehicle.DeleteFdpDerivativeMapping(FdpDerivativeMapping.FromParameters(parameters));

            if (derivativeMappingView.DerivativeMapping is EmptyFdpDerivativeMapping)
            {
                return(JsonGetFailure(string.Format("DerivativeMapping '{0}' could not be deleted", derivativeMappingView.DerivativeMapping.ImportDerivativeCode)));
            }

            return(JsonGetSuccess());
        }