コード例 #1
0
 // 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);
 }
コード例 #2
0
 // 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);
 }
コード例 #3
0
        // 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));
        }
コード例 #4
0
 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));
     }
 }
コード例 #5
0
 public ActionResult Create([Bind(Include = "DivisionId,DivisionName,Active")] ptDivision division)
 {
     if (Pubtracker2FrontEnd.ptHelper.Create <ptDivision>("divisions", division))
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View(division));
     }
 }
コード例 #6
0
        // 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));
        }
コード例 #7
0
 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
コード例 #8
0
 // GET: api/Divisions/5
 public string Get(string id)
     { 
       ptDivision item = ptsHelper.GetAllDivisions().Find(x => x.DivisionId == id);
       return JsonConvert.SerializeObject(item);
     }