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