Exemplo n.º 1
0
 // 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);
 }
Exemplo n.º 2
0
 // 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);
 }
Exemplo n.º 3
0
        // 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));
        }
Exemplo n.º 4
0
 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));
     }
 }
Exemplo n.º 5
0
 public ActionResult Create([Bind(Include = "RoleId,RoleName,Active")] ptRole Role)
 {
     if (Pubtracker2FrontEnd.ptHelper.Create <ptRole>("roles", Role))
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View(Role));
     }
 }
Exemplo n.º 6
0
        // 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));
        }
Exemplo n.º 7
0
        }//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
Exemplo n.º 8
0
 // GET: api/Roles/5
 public string Get(string id)
 {
     ptRole item = ptsHelper.GetAllRoles().Find(x => x.RoleId == id);
     return JsonConvert.SerializeObject(item);
 }