Example #1
0
        public ActionResult DeleteRedirect(Guid redirectId)
        {
            try {
                // Get a reference to the redirect
                IRedirect redirect = _redirects.GetRedirectByKey(redirectId);
                if (redirect == null)
                {
                    throw new RedirectNotFoundException();
                }

                // Delete the redirect
                _redirects.DeleteRedirect(redirect);

                // Map the result for the API
                return(new JsonResult(_backOffice.Map(redirect)));
            } catch (RedirectsException ex) {
                if (!ex.Is404)
                {
                    _logger.LogError(ex, ex.Message);
                }

                // Generate the error response
                return(Error(ex));
            }
        }
Example #2
0
        public object DeleteRedirect(Guid redirectId)
        {
            try {
                // Get a reference to the redirect
                RedirectItem redirect = _redirects.GetRedirectByKey(redirectId);
                if (redirect == null)
                {
                    throw new RedirectNotFoundException();
                }

                // Delete the redirect
                _redirects.DeleteRedirect(redirect);

                // Return the redirect
                return(redirect);
            } catch (RedirectsException ex) {
                // Generate the error response
                return(Request.CreateResponse(JsonMetaResponse.GetError(HttpStatusCode.InternalServerError, ex.Message)));
            }
        }