本文整理汇总了C#中System.Web.Mvc.SelectListItem.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SelectListItem.ToString方法的具体用法?C# SelectListItem.ToString怎么用?C# SelectListItem.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.SelectListItem
的用法示例。
在下文中一共展示了SelectListItem.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreditCard
public ActionResult CreditCard(int? id, string wid)
{
if (!GlobalConfig.IsCreditCardPaymentModeEnabled)
return PartialView("PaymentTemplates/_CreditCardDownTimePartial");
ArrayList list = new ArrayList();
for (int i = 0; i < 12; i++)
{
SelectListItem item = new SelectListItem()
{
Value = (i + 1).ToString(),
Text = DateTimeFormatInfo.CurrentInfo.GetMonthName(i + 1)
};
list.Add(item);
}
ViewBag.Months = list;
list = new ArrayList();
int currentYear = DateTime.Now.Year;
for (int i = currentYear; i <= currentYear + 20; i++)
{
SelectListItem item = new SelectListItem()
{
Value = i.ToString(),
Text = i.ToString()
};
list.Add(item);
}
ViewBag.Years = list;
var registDt = DateTime.Now;
if (id == null)
return PartialView("PaymentTemplates/_BuyErrorPartial");
var context = new IPTV2Entities();
Product product = context.Products.FirstOrDefault(p => p.ProductId == id);
if (product == null)
return PartialView("PaymentTemplates/_BuyErrorPartial");
if (!product.IsForSale)
return PartialView("PaymentTemplates/_BuyErrorPartial");
ViewBag.ProductId = product.ProductId;
ViewBag.WishlistId = wid;
User user = context.Users.FirstOrDefault(u => u.UserId == new System.Guid(User.Identity.Name));
var offering = context.Offerings.Find(GlobalConfig.offeringId);
if (user != null)
{
if (user.HasPendingGomsChangeCountryTransaction(offering))
return PartialView("PaymentTemplates/_BuyPendingChangeCountryErrorPartial");
if (user.HasExceededMaximumPaymentTransactionsForTheDay(GlobalConfig.paymentTransactionMaximumThreshold, registDt))
return PartialView("PaymentTemplates/_BuyErrorExceededMaximumThresholdPartial");
}
ViewBag.User = user;
var ccTypes = user.Country.GetGomsCreditCardTypes();
List<TFCTV.Helpers.CreditCard> clist = new List<TFCTV.Helpers.CreditCard>();
foreach (var item in ccTypes)
clist.Add(new TFCTV.Helpers.CreditCard() { value = ((int)item).ToString(), text = item.ToString().Replace('_', ' ') });
ViewBag.CreditCardList = clist;
if (product == null)
return PartialView("PaymentTemplates/_BuyErrorPartial");
ViewBag.IsSubscriptionProduct = false;
//if (product is SubscriptionProduct)
if (product is PackageSubscriptionProduct)
ViewBag.IsSubscriptionProduct = true;
ViewBag.HasCreditCardEnrolled = false;
if (GlobalConfig.IsRecurringBillingEnabled)
{
var UserCreditCard = user.CreditCards.FirstOrDefault(c => c.StatusId == GlobalConfig.Visible && c.OfferingId == offering.OfferingId);
if (UserCreditCard != null)
{
ViewBag.HasCreditCardEnrolled = true;
ViewBag.UserCreditCard = UserCreditCard;
}
var checkIfEnrolled = CheckIfUserIsEnrolledToSameRecurringProductGroup(context, offering, user, product);
if (checkIfEnrolled.value)
return PartialView("PaymentTemplates/_IsEnrolledToRecurringPartial", checkIfEnrolled.container);
}
return PartialView("PaymentTemplates/_BuyViaCreditCardPartial");
}
示例2: CreditCard
public ActionResult CreditCard(int? id, string wid, int? cpid)
{
return RedirectToAction("Details", "Subscribe");
ArrayList list = new ArrayList();
for (int i = 0; i < 12; i++)
{
SelectListItem item = new SelectListItem()
{
Value = (i + 1).ToString(),
Text = DateTimeFormatInfo.CurrentInfo.GetMonthName(i + 1)
};
list.Add(item);
}
ViewBag.Months = list;
list = new ArrayList();
int currentYear = DateTime.Now.Year;
for (int i = currentYear; i <= currentYear + 20; i++)
{
SelectListItem item = new SelectListItem()
{
Value = i.ToString(),
Text = i.ToString()
};
list.Add(item);
}
ViewBag.Years = list;
if (!MyUtility.isUserLoggedIn())
return RedirectToAction("Index", "Home");
if (id == null)
return RedirectToAction("Index", "Home");
DateTime registDt = DateTime.Now;
ViewBag.HasError = false;
var context = new IPTV2Entities();
var UserId = new Guid(User.Identity.Name);
var user = context.Users.FirstOrDefault(u => u.UserId == UserId);
if (user == null)
return RedirectToAction("Index", "Home");
if (!GlobalConfig.IsCreditCardPaymentModeEnabled)
{
ViewBag.HasError = true;
ViewBag.ErrorEncountered = PaymentError.CREDIT_CARD_PAYMENT_IS_DISABLED;
}
var offering = context.Offerings.Find(GlobalConfig.offeringId);
if (user.HasPendingGomsChangeCountryTransaction(offering))
{
ViewBag.HasError = true;
ViewBag.ErrorEncountered = PaymentError.PENDING_GOMS_CHANGE_COUNTRY;
}
if (user.HasExceededMaximumPaymentTransactionsForTheDay(GlobalConfig.paymentTransactionMaximumThreshold, registDt))
{
ViewBag.HasError = true;
ViewBag.ErrorEncountered = PaymentError.MAXIMUM_TRANSACTION_THRESHOLD_REACHED;
}
//Get Credit Card List
var ccTypes = user.Country.GetGomsCreditCardTypes();
if (ccTypes == null)
{
ViewBag.HasError = true;
ViewBag.ErrorEncountered = PaymentError.CREDIT_CARD_IS_NOT_AVAILABLE_IN_YOUR_AREA;
return View();
}
List<TFCTV.Helpers.CreditCard> clist = new List<TFCTV.Helpers.CreditCard>();
foreach (var item in ccTypes)
clist.Add(new TFCTV.Helpers.CreditCard() { value = ((int)item).ToString(), text = item.ToString().Replace('_', ' ') });
ViewBag.CreditCardList = clist;
var product = context.Products.FirstOrDefault(p => p.ProductId == id);
if (product != null)
{
if (!ContextHelper.IsProductViewableInUserCountry(product))
return RedirectToAction("Index", "Home");
var UserCurrencyCode = user.Country.CurrencyCode;
var productPrice = product.ProductPrices.FirstOrDefault(p => p.CurrencyCode == UserCurrencyCode);
if (productPrice == null)
productPrice = product.ProductPrices.FirstOrDefault(p => p.CurrencyCode == GlobalConfig.DefaultCurrency);
ViewBag.ProductPrice = productPrice;
ViewBag.IsSubscriptionProduct = false;
if (product is PackageSubscriptionProduct)
{
if (((PackageSubscriptionProduct)product).ProductGroup.ProductSubscriptionTypeId == null)
ViewBag.IsSubscriptionProduct = true;
}
ViewBag.HasCreditCardEnrolled = false;
if (GlobalConfig.IsRecurringBillingEnabled)
{
var UserCreditCard = user.CreditCards.FirstOrDefault(c => c.StatusId == GlobalConfig.Visible && c.OfferingId == offering.OfferingId);
if (UserCreditCard != null)
{
//.........这里部分代码省略.........
示例3: CreditCard
public ActionResult CreditCard()
{
if (!GlobalConfig.IsCreditCardReloadModeEnabled)
return PartialView("PaymentTemplates/_CreditCardDownTimePartial");
ArrayList list = new ArrayList();
for (int i = 0; i < 12; i++)
{
SelectListItem item = new SelectListItem()
{
Value = (i + 1).ToString(),
Text = DateTimeFormatInfo.CurrentInfo.GetMonthName(i + 1)
};
list.Add(item);
}
ViewBag.Months = list;
list = new ArrayList();
int currentYear = DateTime.Now.Year;
for (int i = currentYear; i <= currentYear + 20; i++)
{
SelectListItem item = new SelectListItem()
{
Value = i.ToString(),
Text = i.ToString()
};
list.Add(item);
}
ViewBag.Years = list;
var context = new IPTV2Entities();
User user = context.Users.FirstOrDefault(u => u.UserId == new System.Guid(User.Identity.Name));
if (user != null)
{
var offering = context.Offerings.Find(GlobalConfig.offeringId);
var registDt = DateTime.Now;
if (user.HasPendingGomsChangeCountryTransaction(offering))
return PartialView("PaymentTemplates/_BuyPendingChangeCountryErrorPartial");
if (user.HasExceededMaximumReloadTransactionsForTheDay(GlobalConfig.reloadTransactionMaximumThreshold, registDt))
return PartialView("PaymentTemplates/_BuyErrorExceededMaximumThresholdPartial");
}
var ccTypes = user.Country.GetGomsCreditCardTypes();
List<TFCTV.Helpers.CreditCard> clist = new List<TFCTV.Helpers.CreditCard>();
foreach (var item in ccTypes)
clist.Add(new TFCTV.Helpers.CreditCard() { value = ((int)item).ToString(), text = item.ToString().Replace('_', ' ') });
ViewBag.CreditCardList = clist;
ViewBag.Currency = user.Country.Currency.Code;
return PartialView("_ReloadViaCreditCardPartial");
}
示例4: Index
public ActionResult Index()
{
try
{
if (!User.Identity.IsAuthenticated)
return RedirectToAction("Index", "Home");
var context = new IPTV2Entities();
var UserId = new Guid(User.Identity.Name);
var CountryCode = MyUtility.GetCountryCodeViaIpAddressWithoutProxy();
var user = context.Users.FirstOrDefault(u => u.UserId == UserId);
if (user != null)
CountryCode = user.CountryCode;
//Get User's Wallet
var wallet = user.UserWallets.FirstOrDefault(u => u.IsActive && String.Compare(u.Currency, user.Country.CurrencyCode, true) == 0);
if (wallet == null)
return RedirectToAction("Index", "Home");
else
ViewBag.UserWallet = wallet;
//Credit card
try
{
ArrayList list = new ArrayList();
for (int i = 0; i < 12; i++)
{
SelectListItem item = new SelectListItem()
{
Value = (i + 1).ToString(),
Text = DateTimeFormatInfo.CurrentInfo.GetMonthName(i + 1)
};
list.Add(item);
}
ViewBag.Months = list;
list = new ArrayList();
int currentYear = DateTime.Now.Year;
for (int i = currentYear; i <= currentYear + 20; i++)
{
SelectListItem item = new SelectListItem()
{
Value = i.ToString(),
Text = i.ToString()
};
list.Add(item);
}
ViewBag.Years = list;
ViewBag.CreditCardAvailability = true;
var ccTypes = user.Country.GetGomsCreditCardTypes();
if (user.Country.GomsSubsidiaryId != GlobalConfig.MiddleEastGomsSubsidiaryId)
ccTypes = user.Country.GetGomsCreditCardTypes();
else
{
var listOfMiddleEastAllowedCountries = GlobalConfig.MECountriesAllowedForCreditCard.Split(',');
if (listOfMiddleEastAllowedCountries.Contains(user.Country.Code))
ccTypes = user.Country.GetGomsCreditCardTypes();
else
ccTypes = null;
}
if (ccTypes == null)
ViewBag.CreditCardAvailability = false;
else
{
List<TFCTV.Helpers.CreditCard> clist = new List<TFCTV.Helpers.CreditCard>();
foreach (var item in ccTypes)
clist.Add(new TFCTV.Helpers.CreditCard() { value = ((int)item).ToString(), text = item.ToString().Replace('_', ' ') });
ViewBag.CreditCardList = clist;
}
}
catch (Exception) { }
//Mopay
try
{
if (user.Country.MopayButtons.Count(m => m.StatusId == GlobalConfig.Visible) > 0)
{
var buttonIds = user.Country.MopayButtons.Where(m => m.StatusId == GlobalConfig.Visible).OrderBy(m => m.Amount);
if (buttonIds != null)
ViewBag.MopayButtonIds = buttonIds.ToList();
}
}
catch (Exception) { }
//SmartPit
ViewBag.IsSmartPitAvailable = false;
try
{
if (String.Compare(user.CountryCode, GlobalConfig.JapanCountryCode, true) == 0)
ViewBag.IsSmartPitAvailable = true;
if (!String.IsNullOrEmpty(user.SmartPitId))
ViewBag.SmartPitCardNumber = user.SmartPitId;
}
//.........这里部分代码省略.........
示例5: CreditCard
public ActionResult CreditCard()
{
return RedirectToAction("Index", "Load");
ArrayList list = new ArrayList();
for (int i = 0; i < 12; i++)
{
SelectListItem item = new SelectListItem()
{
Value = (i + 1).ToString(),
Text = DateTimeFormatInfo.CurrentInfo.GetMonthName(i + 1)
};
list.Add(item);
}
ViewBag.Months = list;
list = new ArrayList();
int currentYear = DateTime.Now.Year;
for (int i = currentYear; i <= currentYear + 20; i++)
{
SelectListItem item = new SelectListItem()
{
Value = i.ToString(),
Text = i.ToString()
};
list.Add(item);
}
ViewBag.Years = list;
if (!MyUtility.isUserLoggedIn())
return RedirectToAction("Index", "Home");
if (!GlobalConfig.IsCreditCardReloadModeEnabled)
{
ViewBag.HasError = true;
ViewBag.ErrorEncountered = ReloadError.CREDIT_CARD_RELOAD_IS_DISABLED;
return View();
}
DateTime registDt = DateTime.Now;
ViewBag.HasError = false;
var context = new IPTV2Entities();
var UserId = new Guid(User.Identity.Name);
var user = context.Users.FirstOrDefault(u => u.UserId == UserId);
if (user == null)
return RedirectToAction("Index", "Home");
var userWallet = user.UserWallets.FirstOrDefault(u => u.Currency == user.Country.CurrencyCode && u.IsActive == true);
if (userWallet == null)
return RedirectToAction("Index", "Home");
var offering = context.Offerings.Find(GlobalConfig.offeringId);
if (user.HasPendingGomsChangeCountryTransaction(offering))
{
ViewBag.HasError = true;
ViewBag.ErrorEncountered = ReloadError.PENDING_GOMS_CHANGE_COUNTRY;
}
if (user.HasExceededMaximumReloadTransactionsForTheDay(GlobalConfig.reloadTransactionMaximumThreshold, registDt))
{
ViewBag.HasError = true;
ViewBag.ErrorEncountered = ReloadError.MAXIMUM_TRANSACTION_THRESHOLD_REACHED;
}
//Get Credit Card List
var ccTypes = user.Country.GetGomsCreditCardTypes();
if (ccTypes == null)
{
ViewBag.HasError = true;
ViewBag.ErrorEncountered = ReloadError.CREDIT_CARD_IS_NOT_AVAILABLE_IN_YOUR_AREA;
return View();
}
List<TFCTV.Helpers.CreditCard> clist = new List<TFCTV.Helpers.CreditCard>();
foreach (var item in ccTypes)
clist.Add(new TFCTV.Helpers.CreditCard() { value = ((int)item).ToString(), text = item.ToString().Replace('_', ' ') });
ViewBag.CreditCardList = clist;
ViewBag.User = user;
ViewBag.UserWallet = userWallet;
return View();
}
示例6: Details
public ActionResult Details(string id, int? PackageOption, int? ProductOption)
{
var profiler = MiniProfiler.Current;
#region if (!Request.Cookies.AllKeys.Contains("version"))
if (!Request.Cookies.AllKeys.Contains("version"))
{
List<SubscriptionProductA> productList = null;
try
{
if (!String.IsNullOrEmpty(id))
if (String.Compare(id, "mayweather-vs-pacquiao-may-3", true) == 0)
id = GlobalConfig.PacMaySubscribeCategoryId.ToString();
var context = new IPTV2Entities();
string ip = Request.IsLocal ? "78.95.139.99" : Request.GetUserHostAddressFromCloudflare();
if (GlobalConfig.isUAT && !String.IsNullOrEmpty(Request.QueryString["ip"]))
ip = Request.QueryString["ip"].ToString();
var location = MyUtility.GetLocationBasedOnIpAddress(ip);
var CountryCode = location.countryCode;
//var CountryCode = MyUtility.GetCountryCodeViaIpAddressWithoutProxy();
User user = null;
Guid? UserId = null;
if (User.Identity.IsAuthenticated)
{
UserId = new Guid(User.Identity.Name);
user = context.Users.FirstOrDefault(u => u.UserId == UserId);
if (user != null)
CountryCode = user.CountryCode;
}
var country = context.Countries.FirstOrDefault(c => String.Compare(c.Code, CountryCode, true) == 0);
var premium = MyUtility.StringToIntList(GlobalConfig.PremiumProductIds);
var lite = MyUtility.StringToIntList(GlobalConfig.LiteProductIds);
var movie = MyUtility.StringToIntList(GlobalConfig.MovieProductIds);
var litepromo = MyUtility.StringToIntList(GlobalConfig.LitePromoProductIds);
var promo2014promo = MyUtility.StringToIntList(GlobalConfig.Promo2014ProductIds);
var q22015promo = MyUtility.StringToIntList(GlobalConfig.Q22015ProductId);
var productIds = premium;//productids
var offering = context.Offerings.Find(GlobalConfig.offeringId);
var service = offering.Services.FirstOrDefault(o => o.PackageId == GlobalConfig.serviceId);
bool IsAlaCarteProduct = true;
#region code for showing product based on id
if (!String.IsNullOrEmpty(id))
{
int pid;
if (int.TryParse(id, out pid)) // id is an integer, then it's a show, get ala carte only
{
var show = (Show)context.CategoryClasses.Find(pid);
if (User.Identity.IsAuthenticated)
{
var allowedEmails = GlobalConfig.EmailsAllowedToBypassIPBlock.Split(',');
var isEmailAllowed = allowedEmails.Contains(user.EMail.ToLower());
if (!isEmailAllowed)
{
if (!ContextHelper.IsCategoryViewableInUserCountry(show, CountryCode))
return RedirectToAction("Index", "Home");
string CountryCodeBasedOnIpAddress = MyUtility.GetCountryCodeViaIpAddressWithoutProxy();
if (!ContextHelper.IsCategoryViewableInUserCountry(show, CountryCodeBasedOnIpAddress))
return RedirectToAction("Index", "Home");
}
}
try
{
var ShowParentCategories = ContextHelper.GetShowParentCategories(show.CategoryId);
if (!String.IsNullOrEmpty(ShowParentCategories))
{
ViewBag.ShowParentCategories = ShowParentCategories;
if (!MyUtility.IsWhiteListed(String.Empty))
{
var ids = MyUtility.StringToIntList(ShowParentCategories);
var alaCarteIds = MyUtility.StringToIntList(GlobalConfig.UXAlaCarteParentCategoryIds);
var DoCheckForGeoIPRestriction = ids.Intersect(alaCarteIds).Count() > 0;
if (DoCheckForGeoIPRestriction)
{
var ipx = Request.IsLocal ? "221.121.187.253" : String.Empty;
if (GlobalConfig.isUAT)
ipx = Request["ip"];
if (!MyUtility.CheckIfCategoryIsAllowed(show.CategoryId, context, ipx))
{
var ReturnCode = new TransactionReturnType()
{
StatusHeader = "Content Advisory",
StatusMessage = "This content is currently not available in your area.",
StatusMessage2 = "You may select from among the hundreds of shows and movies that are available on the site."
};
TempData["ErrorMessage"] = ReturnCode;
return RedirectToAction("Index", "Home");
}
}
}
}
}
catch (Exception) { }
//.........这里部分代码省略.........
示例7: Details
public ActionResult Details(string id, int? PackageOption, int? ProductOption)
{
var profiler = MiniProfiler.Current;
#region if (!Request.Cookies.AllKeys.Contains("version"))
if (!Request.Cookies.AllKeys.Contains("version"))
{
List<SubscriptionProductA> productList = null;
try
{
#region if user is not loggedin
if (!User.Identity.IsAuthenticated)
{
if (!String.IsNullOrEmpty(id))
{
if (String.Compare(id, "mayweather-vs-pacquiao-may-3", true) == 0)
{
HttpCookie pacMayCookie = new HttpCookie("redirect3178");
pacMayCookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(pacMayCookie);
id = GlobalConfig.PacMaySubscribeCategoryId.ToString();
}
if (String.Compare(id, GlobalConfig.PacMaySubscribeCategoryId.ToString(), true) != 0)
{
TempData["LoginErrorMessage"] = "Please register or sign in to avail of this promo.";
TempData["RedirectUrl"] = Request.Url.PathAndQuery;
if (String.Compare(id, "lckbprea", true) == 0)
{
HttpCookie preBlackCookie = new HttpCookie("redirectlckbprea");
preBlackCookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(preBlackCookie);
}
else if (String.Compare(id, "Promo201410", true) == 0)
{
HttpCookie promo2014010 = new HttpCookie("promo2014cok");
promo2014010.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(promo2014010);
}
else if (String.Compare(id, "aintone", true) == 0)
{
HttpCookie preBlackCookie = new HttpCookie("redirectaintone");
preBlackCookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(preBlackCookie);
}
//check if id is integer
try
{
int tempId = 0;
if (Int32.TryParse(id, out tempId))
{
TempData["LoginErrorMessage"] = "Please sign in to purchase this product.";
TempData["RedirectUrl"] = Request.Url.PathAndQuery;
if (Request.Browser.IsMobileDevice)
return RedirectToAction("MobileSignin", "User", new { ReturnUrl = Server.UrlEncode(Request.Url.PathAndQuery) });
else
return RedirectToAction("Login", "User", new { ReturnUrl = Server.UrlEncode(Request.Url.PathAndQuery) });
}
}
catch (Exception) { }
if (Request.Browser.IsMobileDevice)
return RedirectToAction("MobileSignin", "User");
else
return RedirectToAction("Login", "User");
}
}
else
{
TempData["LoginErrorMessage"] = "Please register or sign in to subscribe.";
TempData["RedirectUrl"] = Request.Url.PathAndQuery;
if (Request.Browser.IsMobileDevice)
return RedirectToAction("MobileSignin", "User");
else
return RedirectToAction("Login", "User");
}
}
#endregion
#region user authenticated flow
else
if (!String.IsNullOrEmpty(id))
if (String.Compare(id, "mayweather-vs-pacquiao-may-3", true) == 0)
id = GlobalConfig.PacMaySubscribeCategoryId.ToString();
var context = new IPTV2Entities();
string ip = Request.IsLocal ? "78.95.139.99" : Request.GetUserHostAddressFromCloudflare();
if (GlobalConfig.isUAT && !String.IsNullOrEmpty(Request.QueryString["ip"]))
ip = Request.QueryString["ip"].ToString();
var location = MyUtility.GetLocationBasedOnIpAddress(ip);
var CountryCode = location.countryCode;
//var CountryCode = MyUtility.GetCountryCodeViaIpAddressWithoutProxy();
User user = null;
Guid? UserId = null;
if (User.Identity.IsAuthenticated)
//.........这里部分代码省略.........