Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        public ActionResult Create(PickupDB pickupdb)
        {
            List<string> PropertyNames = new List<string>() { "firstn", "lastn", "number", "address", "pincode" };

            if (PropertyNames.Any(p => !ModelState.IsValidField(p)))
            {
                return View(pickupdb);                    // Error
            }
            else
            {
                return RedirectToAction("Date", pickupdb);     // Everything is okay
            }
        }
Exemplo n.º 3
0
        public ActionResult Create(List list)
        {
            list.bid = TempData["bid"] as string;
            if (ModelState.IsValid)
            {
                list.listPos = db.Lists.Where<List>(l => l.bid == list.bid).Count() + 1;
                db.Lists.Add(list);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.bid = list.bid;
            return View(list);
        }
Exemplo n.º 4
0
        public HttpResponseMessage All()
        {
            var result = new Dictionary<string, List<DictItem>>();

            var specs = new List<string> {"alpinist", "tehnogenschik"};

            foreach (var spec in specs)
            {
                var dict = (new Dict()).Get(spec);
                dict.Insert(0, new DictItem {Id = 0, Name = " "});
                result.Add(spec, dict);
            }
            var response = Request.CreateResponse<Dictionary<string, List<DictItem>>>(HttpStatusCode.OK, result);

            // set it to expire in 5 minutes
            response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now.AddSeconds(30));
            return response;
        }
Exemplo n.º 5
0
 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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        public ActionResult Edit(List list)
        {
            if (ModelState.IsValid)
            {

                int newPos = list.listPos;
                int oldPos = (int)TempData["oldPos"];
                list.listPos = oldPos;
                db.Entry(list).State = EntityState.Modified;
                db.Lists.Remove(list);
                db.SaveChanges();
                List otherList = db.Lists.First<List>(l => l.listPos == newPos);
                db.Entry(otherList).State = EntityState.Modified;
                db.Lists.Remove(otherList);
                db.SaveChanges();
                list.listPos = newPos;
                db.Lists.Add(list);
                db.SaveChanges();
                otherList.listPos = oldPos;
                db.Lists.Add(otherList);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.bid = list.bid;
            return View(list);
        }
Exemplo n.º 9
0
 public ActionResult Edit(PickupDB pickupdb)
 {
     List<string> PropertyNames = new List<string>() { "firstn", "lastn", "number", "address", "pincode" };
     if (PropertyNames.Any(p => !ModelState.IsValidField(p)))
     {
         return View(pickupdb);                    // Error
     }
     else
     {
         db.Entry(pickupdb).State = EntityState.Modified;
         db.Configuration.ValidateOnSaveEnabled = false;
         db.SaveChanges();
         return RedirectToAction("Index", "Home");
     }
 }