Пример #1
0
        public ActionResult CommandConfig(string commandName)
        {
            var command = TopbarCommands.GetCommand(commandName);
            var config  = command.GetDefaultConfig() ?? Activator.CreateInstance(command.ConfigType);

            ViewBag.Command = command;

            return(PartialView(config));
        }
Пример #2
0
        public ActionResult ExecuteCommand(string commandName, string itemType, CommandDataItem[] model, [ModelBinder(typeof(BindingTypeAwareModelBinder))] object config = null)
        {
            var command    = TopbarCommands.GetCommand(commandName);
            var entityType = Type.GetType(itemType, true);
            var repository = CurrentInstance.Database.Repository(entityType);
            var idProperty = EntityKey.GetKeyProperty(entityType);
            var items      = new List <object>();

            foreach (var each in model)
            {
                var id   = Convert.ChangeType(each.Id, idProperty.PropertyType);
                var item = repository.Find(id);
                items.Add(item);
            }

            var result = command.Execute(items, config, CurrentInstance);

            if (result == null)
            {
                result = AjaxForm().ReloadPage();
            }

            return(result);
        }