Пример #1
0
        public ActionResult Edit(int id)
        {
            var customer = _customerService.Find(id);
            var model    = Mapper.Map <Customer, CustomerEditorModel>(customer);

            ViewBag.ToolbarCommands = TopbarCommands.GetCommands(ControllerContext, customer, CurrentInstance);

            return(View(model));
        }
Пример #2
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));
        }
Пример #3
0
        public ActionResult Detail(int id)
        {
            var order = _orderService.Find(id);

            ViewBag.ToolbarCommands = TopbarCommands.GetCommands(ControllerContext, order, CurrentInstance).ToList();
            ViewBag.Return          = "/Commerce/Order?siteName=" + Request.QueryString["siteName"] + "&instance=" + Request.QueryString["instance"];

            return(View(order));
        }
Пример #4
0
        private void PrepareProductEditing(ProductType productType, Product product)
        {
            if (product != null)
            {
                ViewBag.Product         = product;
                ViewBag.ToolbarCommands = TopbarCommands.GetCommands(ControllerContext, product, CurrentInstance);
            }

            ViewBag.ProductType         = productType;
            ViewBag.DefaultVariantModel = CreateDefaultVariantModel(productType);
            ViewBag.ImageTypes          = _settingService.Get <GlobalSettings>().Image.Types;

            var settings = _settingService.Get <GlobalSettings>();

            if (settings != null && !String.IsNullOrEmpty(settings.Currency))
            {
                ViewBag.CurrencySymbol = CurrencyInfo.GetCurrencyInfoByISOSymbol(settings.Currency).Symbol;
            }

            this.LoadTabPlugins();
        }
Пример #5
0
        public override System.Web.IHtmlString RenderItemContainerAtts()
        {
            var model = DataItem as IOrderModel;

            if (model == null)
            {
                return(MvcHtmlString.Empty);
            }

            var instance = CommerceInstance.Current;
            var order    = instance.Database.Repository <Order>().Find(model.Id);

            var classes = new List <string>();

            foreach (var button in TopbarCommands.GetCommands(GridModel.ViewContext.Controller.ControllerContext, order, instance))
            {
                classes.Add("cmd-" + button.Name);
            }

            return(MvcHtmlString.Create(String.Format("class='{0}'", String.Join(" ", classes))));
        }
Пример #6
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);
        }