Пример #1
0
        public object ExecuteDelete(IEngineContext context, IController controller, IControllerContext controllerContext)
        {
            using (var transaction = new TransactionScope()) {
                var instance = AR.Find <T>(context.GetParameter("id"));
                try {
                    OnPreDelete(controller, instance);
                    AR.Delete <T>(instance);
                    OnPostDelete(controller, instance);

                    transaction.Flush();
                    transaction.VoteCommit();

                    context.SuccessMessage(instance + " has been deleted");
                } catch (Exception ex) {
                    transaction.VoteRollBack();
                    context.ErrorMessages(ex);
                } finally {
                    controllerContext.PropertyBag[TemplateObjectName] = instance;
                    context.Flash[TemplateObjectName] = instance;
                }
            }

            return(null);
        }