public List<DictItem> Get(string prefix) { var dict = new List<DictItem>(); for (var i = 1; i < 10; i++) { dict.Add(new DictItem {Id = i, Name = string.Format("{0} {1} name", prefix, i)}); } return dict; }
public JsonResult QueryList(int pageIndex) { List<Table1> lst = new List<Table1>(); using (SQLiteConnection conn = new SQLiteConnection(System.Configuration.ConfigurationManager.ConnectionStrings["sqliteConnection"].ConnectionString)) { conn.Open(); SQLiteCommand cmd = new SQLiteCommand("select * from table1 " + (pageIndex > 0 ? "limit 10 Offset " + ((pageIndex-1)* 10) : ""), conn); //SQLiteDataAdapter da = new SQLiteDataAdapter(cmd); //System.Data.DataTable dt = new System.Data.DataTable(); //da.Fill(dt); SQLiteDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Table1 t1 = new Table1() { ID = dr.GetInt32(0), Title = dr.GetString(1) }; lst.Add(t1); } conn.Close(); } return Json(lst,JsonRequestBehavior.AllowGet); }
public ActionResult Index() { SampleDBContext db = new SampleDBContext(); List<SelectListItem> listSelectListItem = new List<SelectListItem>(); foreach (City city in db.Cities) { SelectListItem selectListItem = new SelectListItem() { Text = city.Name, Value = city.ID.ToString(), Selected = city.IsSelected }; listSelectListItem.Add(selectListItem); } CitiesViewModel citiesViewModel = new CitiesViewModel(); citiesViewModel.Cities = listSelectListItem; return View(citiesViewModel); }
public ActionResult RemoveExternalLogins() { ICollection<OAuthAccount> accounts = OAuthWebSecurity.GetAccountsFromUserName(User.Identity.Name); List<ExternalLogin> externalLogins = new List<ExternalLogin>(); foreach (OAuthAccount account in accounts) { AuthenticationClientData clientData = OAuthWebSecurity.GetOAuthClientData(account.Provider); externalLogins.Add(new ExternalLogin { Provider = account.Provider, ProviderDisplayName = clientData.DisplayName, ProviderUserId = account.ProviderUserId, }); } ViewBag.ShowRemoveButton = externalLogins.Count > 1 || OAuthWebSecurity.HasLocalAccount(WebSecurity.GetUserId(User.Identity.Name)); return PartialView("_RemoveExternalLoginsPartial", externalLogins); }