public ActionResult Edit(string id) { var menu = _repository.Get(p => p.Id == id); var model = new WxMenuModel(); model.Id = menu.Id; model.Bind = menu.Bind; model.BindTopic = menu.Content; model.BindValue = menu.ReplyId; model.Name = menu.Name; model.CreateDateTime = menu.CreateDateTime; model.Url = menu.Content; model.Sequence = menu.Sequence; model.ParentMenu = _repository.Get(x => x.Id == menu.ParentId); model.BindTypes = SelectListItems.FromEnum(menu.Bind).ToArray(); model.Keywords = _wxReplyRepository.Query() .Select(x => new { x.Sequence, x.Id, x.Content }) .OrderByDescending(x => x.Sequence) .ToList() .Select(x => new SelectListItem { Value = x.Id, Text = x.Content, Selected = x.Id == menu.Content }).ToArray(); model.Topics = new SelectListItem[] { }; return(View(model)); }
public IEnumerable <System.Web.Mvc.SelectListItem> GetSelectListItems(System.Web.Routing.RequestContext requestContext, string filter = null) { var items = SelectListItems.FromEnum <OrderStatus>(); items.Insert(0, new System.Web.Mvc.SelectListItem { Text = "", Value = "" }); return(items); }
public ActionResult Add(BindType?bind, string parentId) { var model = new WxMenuModel() { Bind = bind.GetValueOrDefault(), ParentId = parentId }; model.BindTypes = SelectListItems.FromEnum(bind.GetValueOrDefault()).ToArray(); model.Keywords = _wxReplyRepository.Query() .Select(x => new { x.Sequence, x.Id, x.Content }) .OrderByDescending(x => x.Sequence) .ToList() .Select(x => new SelectListItem { Value = x.Id, Text = x.Content }).ToArray(); model.Topics = new SelectListItem[] { }; return(View(model)); }
public PaymentMethodEditorModel() { AvailablePaymentProcessors = new List <PaymentProcessorModel>(); AllFeeChargeModes = SelectListItems.FromEnum(typeof(PaymentMethodFeeChargeMode)); }
public ConfigModel() { AvailableDiscountModes = SelectListItems.FromEnum <DiscountMode>(); AvailableDiscountAppliedTos = SelectListItems.FromEnum <DiscountAppliedTo>(); }
public PromotionEditorModel() { OtherPromotions = new List <PromotionRowModel>(); AvailableOverlappingUsages = SelectListItems.FromEnum(typeof(PromotionOverlappingUsage)); }
public ActionResult Add(WxMenuModel model) { if (ModelState.IsValid) { var isOk = RunWithCatch((ms) => { var entity = new WxMenu(); entity.Name = model.Name; entity.Content = model.BindValue; entity.Bind = model.Bind; entity.Type = model.BindType; entity.ParentId = model.ParentId; entity.Sequence = model.Sequence; BindType bindType = model.Bind; switch (bindType) { case BindType.Key: entity.ReplyId = model.BindValue; break; case BindType.Topic: entity.Content = model.BindTopic; break; default: if (bindType == BindType.Url) { entity.Content = model.Url; } break; } entity.Client = MenuClient.Weixin; entity.Type = "click"; if (entity.ParentId.IsBlank()) { entity.Type = "view"; } else if (entity.Bind == BindType.None) { ms.AddModelError("Bind", "二级菜单必须绑定一个对象"); return(false); } _repository.Insert(entity); return(true); }); if (isOk) { return(RedirectToAction("Index")); } } else { model.BindTypes = SelectListItems.FromEnum(model.Bind).ToArray(); model.Keywords = _wxReplyRepository.Query() .Select(x => new { x.Sequence, x.Id, x.Content }) .OrderByDescending(x => x.Sequence) .ToList() .Select(x => new SelectListItem { Value = x.Id, Text = x.Content, Selected = model.BindValue == x.Id }).ToArray(); model.Topics = new SelectListItem[] { }; } return(View(model)); }
public ByWeightShippingRulesModel() { Rules = new List <ByWeightShippingRuleModel>(); AvailablePriceUnits = SelectListItems.FromEnum <ShippingPriceUnit>(); }