public ActionResult ChannelRestrictionAdd(ChannelRestriction model) { this.SMSUIService.Add <ChannelRestriction>(model); if (model.InstructionId.HasValue) { return(RedirectToAction("ChannelRestrictions", new { instructionId = model.InstructionId })); } return(RedirectToAction("ChannelRestrictions", new { channelId = model.ChannelId })); }
public ActionResult ChannelRestrictionAdd(int?channelId, int?provinceId, int?instructionId) { ChannelRestriction model = new ChannelRestriction(); if (channelId.HasValue) { model.ChannelId = channelId.GetValueOrDefault(); } ViewData["RestrictionType"] = EnumHelper.GetSelectListFromEnumType(typeof(RestrictionType)); ViewData["Province"] = new SelectList(ChinaRegionInfo.AllProvinces, "Id", "Name", provinceId.GetValueOrDefault()); var cities = new List <City> { new City { Id = 0, Name = "请选择", ProvinceId = 0 } }; if (provinceId.HasValue) { var relatedCities = this.SMSService.GetCityByProvinceId(provinceId.GetValueOrDefault()); if (relatedCities != null) { foreach (var c in relatedCities) { cities.Add(new City { Id = c.Id, Name = c.Name, ProvinceId = c.ProvinceId }); } } } ViewData["City"] = new SelectList(cities, "Id", "Name"); ViewData["Operator"] = EnumHelper.GetSelectListFromEnumType(typeof(Operators)); ViewData["TimeSpan"] = EnumHelper.GetSelectListFromEnumType(typeof(RestrictionByTimeSpan)); ViewData["InstructionId"] = instructionId.GetValueOrDefault(); if (instructionId.HasValue) { model.InstructionId = instructionId.GetValueOrDefault(); } TempData["InstructionId"] = instructionId.GetValueOrDefault(); return(View(model)); }