// POST: api/Divisions public void Post(HttpRequestMessage request) { string body = request.Content.ReadAsStringAsync().Result; ptDivision d = JsonConvert.DeserializeObject<ptDivision>(body); string sql = "INSERT INTO [pubtrack].[tblDivisions]([DivisionId],[DivisionName],[Active]) VALUES ('" + d.DivisionId + "','" + d.DivisionName + "','" + d.Active.ToString() + "');"; ptsHelper.ExcecuteSql(sql); }
// PUT: api/Divisions/5 public void Put(string id, HttpRequestMessage request) { string body = request.Content.ReadAsStringAsync().Result; ptDivision d = JsonConvert.DeserializeObject<ptDivision>(body); string sql = "UPDATE [pubtrack].[tblDivisions] SET [DivisionName] = '" + d.DivisionName + "',[Active] = '" + d.Active.ToString() + "' WHERE DivisionId = '" + d.DivisionId + "';"; ptsHelper.ExcecuteSql(sql); }
// POST: api/Divisions public void Post(HttpRequestMessage request) { string json = File.ReadAllText(path); var items = JsonConvert.DeserializeObject <List <ptDivision> >(json); string body = request.Content.ReadAsStringAsync().Result; ptDivision newPub = JsonConvert.DeserializeObject <ptDivision>(body); items.Add(newPub); File.WriteAllText(path, JsonConvert.SerializeObject(items)); }
public ActionResult Edit(string id, [Bind(Include = "DivisionId,DivisionName,Active")] ptDivision division) { if (Pubtracker2FrontEnd.ptHelper.Edit <ptDivision>(id, "divisions", division)) { return(RedirectToAction("Index")); } else { return(View(division)); } }
public ActionResult Create([Bind(Include = "DivisionId,DivisionName,Active")] ptDivision division) { if (Pubtracker2FrontEnd.ptHelper.Create <ptDivision>("divisions", division)) { return(RedirectToAction("Index")); } else { return(View(division)); } }
// PUT: api/Divisions/5 public void Put(string id, HttpRequestMessage request) { string json = File.ReadAllText(path); var items = JsonConvert.DeserializeObject <List <ptDivision> >(json); string body = request.Content.ReadAsStringAsync().Result; ptDivision updatedPub = JsonConvert.DeserializeObject <ptDivision>(body); int index = items.IndexOf(items.Find(x => x.DivisionId == id)); if (index != -1) { items[index] = updatedPub; } File.WriteAllText(path, JsonConvert.SerializeObject(items)); }
public static List<ptDivision> GetAllDivisions() { List<ptDivision> items = new List<ptDivision>(); string sql = "Select * from pubtrack.tblDivisions;"; DataSet ds = ExecuteSPDataSetText(sql, conn); foreach (DataRow r in ds.Tables[0].Rows) { ptDivision item = new ptDivision(); item.DivisionId = r["DivisionId"].ToString(); item.DivisionName = r["DivisionName"].ToString(); item.Active = Convert.ToBoolean(r["Active"].ToString()); items.Add(item); } return items; }//End GetAll Divisions
// GET: api/Divisions/5 public string Get(string id) { ptDivision item = ptsHelper.GetAllDivisions().Find(x => x.DivisionId == id); return JsonConvert.SerializeObject(item); }