public dynamic MoveCustomerKey(CustomerKeyMove customerKeyMove)
        {
            string output;

            try
            {
                if (_customerKeyMoveDataAccess.MoveCustomerKey(customerKeyMove))
                {
                    output = "Key Successfully Moved";
                }
                else
                {
                    output = "Failed to move key for unknown reason";
                }
            }
            catch (Exception ex)
            {
                _logger.Error("MoveCustomerKey ErrorTag: " + ErrorTagProvider.ErrorTagDatabase + " -- " + ex.Message, ex);

                if (ex.GetType() == typeof(DataException))
                {
                    return(new object[] { HttpStatusCode.NotFound, ex.Message });

                    throw new Exception(string.Format(ex.Message, ErrorTagProvider.ErrorTagDatabase));
                }

                throw new Exception(string.Format(DatabaseMessage.DatabaseException, ErrorTagProvider.ErrorTagDatabase));
            }
            return(output);
        }
        public bool MoveCustomerKey(CustomerKeyMove customerKeyMove)
        {
            using (var conn = new SqlConnection(_mciCrDbConnectionString))
            {
                conn.Open();
                // var transaction = conn.BeginTransaction();
                try
                {
                    using (SqlCommand cmd = new SqlCommand("[dbo].[move_mci_key]", conn))
                    {
                        cmd.Parameters.AddWithValue("@p_from_source_key", customerKeyMove?.OriginalSourceKey);
                        cmd.Parameters.AddWithValue("@p_from_source_id", customerKeyMove?.OriginalSourceId);
                        cmd.Parameters.AddWithValue("@p_to_source_key", customerKeyMove?.NewSourceKey);
                        cmd.Parameters.AddWithValue("@p_to_source_id", customerKeyMove?.NewSourceId);
                        cmd.Parameters.AddWithValue("@p_key_to_move", customerKeyMove?.ToMoveSourceKey);
                        cmd.Parameters.AddWithValue("@p_id_to_move", customerKeyMove?.ToMoveSourceId);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.ExecuteScalar();
                    }
                }

                catch (Exception ex)
                {
                    //  transaction.Rollback();
                    _logger.Error(
                        "MoveCustomerKey : ErrorTag: " + ErrorTagProvider.ErrorTagDatabase + " -- " + ex.Message, ex);

                    if (_logParameterValue)
                    {
                        _logger.Error(
                            $"Parameters MoveCustomerKey:- OriginalSourceKey={customerKeyMove.OriginalSourceKey}, OriginalSourceId={customerKeyMove.OriginalSourceId}, NewSourceKey={customerKeyMove.NewSourceKey}, " +
                            $" NewSourceId= {customerKeyMove.NewSourceId}, ToMoveSourceKey={customerKeyMove.ToMoveSourceKey},  ToMoveSourceId={customerKeyMove.ToMoveSourceId}");
                    }

                    switch (ex.Message)
                    {
                    case "Customer Reference not found":
                    case "Source key value pair not found":
                    case "Key to move key value pair not found":
                    case "Key being moved does not belong to FROM customer":
                    case "Failed to move key":
                    {
                        throw new DataException(ex.Message);
                    }
                    }

                    throw new Exception(string.Format(ex.Message, ErrorTagProvider.ErrorTagDatabase));
                }
            }

            return(true);
        }