public ActionResult Add() { StoryModel added = new StoryModel(); added.currentUser = User.Identity.Name; added.title = Request["title"]; added.text = Request["text"]; added.likes = 0; Cords c = new Cords(); string temp = Request["cords"]; string[] i = temp.Split(' '); bool n; try { Convert.ToDecimal(i[1]); Convert.ToDecimal(i[2]); n = true; } catch { n = false; } if (n) { c.x = Convert.ToDecimal(i[1]); c.y = Convert.ToDecimal(i[2]); added.cord.Add(c); } database send = new database(); send.addStory(added); return View("Sandbox", i); }
public List<Cords> getCords(int id) { List<Cords> result = new List<Cords>(); string ConStr = ConfigurationManager.ConnectionStrings["TT2data"].ConnectionString; using (SqlConnection data = new SqlConnection(ConStr)) { data.Open(); SqlCommand sel2 = new SqlCommand("select id, xcord, ycord from cord where id = " + id.ToString(), data); using (SqlDataReader reader = sel2.ExecuteReader()) { while (reader.Read()) { Cords b = new Cords(); b.id = reader.GetInt32(0); b.x = reader.GetDecimal(1); b.y = reader.GetDecimal(2); result.Add(b); } } data.Close(); } return result; }