public JsonResult Delete([FromBody] DeleteResourceRequestModel model)
        {
            if (!_config.HideDeleteButton)
            {
                var cmd = new DeleteResource.Command(model.Key);
                cmd.Execute();
            }

            return(ServiceOperationResult.Ok);
        }
Example #2
0
        public ActionResult Delete([Bind(Prefix = "pk")] string resourceKey, string returnUrl)
        {
            try
            {
                var c = new DeleteResource.Command(resourceKey);
                c.Execute();

                return(Redirect(returnUrl));
            }
            catch (Exception e)
            {
                Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                return(Json(new JsonServiceResult
                {
                    Message = e.Message
                }));
            }
        }
        public ActionResult Delete([Bind(Prefix = "pk")] string resourceKey, string returnUrl)
        {
            try
            {
                var user    = HttpContext.User;
                var isAdmin = user.Identity.IsAuthenticated &&
                              UiConfigurationContext.Current.AuthorizedAdminRoles.Any(r => user.IsInRole(r));

                if (isAdmin && !UiConfigurationContext.Current.HideDeleteButton)
                {
                    var c = new DeleteResource.Command(resourceKey);
                    c.Execute();
                }

                return(Redirect(returnUrl));
            }
            catch (Exception e)
            {
                Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                return(Json(new JsonServiceResult {
                    Message = e.Message
                }));
            }
        }