Example #1
0
 // POST: api/Types
 public void Post(HttpRequestMessage request)
 {
     string body = request.Content.ReadAsStringAsync().Result;
     ptType d = JsonConvert.DeserializeObject<ptType>(body);
     string sql = "INSERT INTO [pubtrack].[tblTypes]([TypeId],[TypeName],[Active]) VALUES ('" +
     d.TypeId + "','" + d.TypeName + "','" + d.Active.ToString() + "');";
     ptsHelper.ExcecuteSql(sql);
 }
Example #2
0
 // PUT: api/Types/5
 public void Put(string id, HttpRequestMessage request)
 {
     string body = request.Content.ReadAsStringAsync().Result;
     ptType d = JsonConvert.DeserializeObject<ptType>(body);
     string sql = "UPDATE [pubtrack].[tblTypes] SET [TypeName] = '" +
     d.TypeName + "',[Active] = '" + d.Active.ToString() +
     "' WHERE TypeId = '" + d.TypeId + "';";
     ptsHelper.ExcecuteSql(sql);
 }
Example #3
0
        // POST api/<controller>
        public void Post(HttpRequestMessage request)
        {
            string json   = File.ReadAllText(path);
            var    items  = JsonConvert.DeserializeObject <List <ptType> >(json);
            string body   = request.Content.ReadAsStringAsync().Result;
            ptType newPub = JsonConvert.DeserializeObject <ptType>(body);

            items.Add(newPub);
            File.WriteAllText(path, JsonConvert.SerializeObject(items));
        }
Example #4
0
 public ActionResult Edit(string id, [Bind(Include = "TypeId,TypeName,Active")] ptType Type)
 {
     if (Pubtracker2FrontEnd.ptHelper.Edit <ptType>(id, "types", Type))
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View(Type));
     }
 }
Example #5
0
 public ActionResult Create([Bind(Include = "TypeId,TypeName,Active")] ptType Type)
 {
     if (Pubtracker2FrontEnd.ptHelper.Create <ptType>("types", Type))
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View(Type));
     }
 }
Example #6
0
        // PUT api/<controller>/5
        public void Put(string id, HttpRequestMessage request)
        {
            string json       = File.ReadAllText(path);
            var    items      = JsonConvert.DeserializeObject <List <ptType> >(json);
            string body       = request.Content.ReadAsStringAsync().Result;
            ptType updatedPub = JsonConvert.DeserializeObject <ptType>(body);
            int    index      = items.IndexOf(items.Find(x => x.TypeId == id));

            if (index != -1)
            {
                items[index] = updatedPub;
            }
            File.WriteAllText(path, JsonConvert.SerializeObject(items));
        }
Example #7
0
        }//End GetAll Steps

        public static List<ptType> GetAllTypes()
        {
            List<ptType> items = new List<ptType>();
            string sql = "Select * from pubtrack.tblTypes;";
            DataSet ds = ExecuteSPDataSetText(sql, conn);
            foreach (DataRow r in ds.Tables[0].Rows)
            {
                ptType item = new ptType();
                item.TypeId = r["TypeId"].ToString();
                item.TypeName = r["TypeName"].ToString();
                item.Active = Convert.ToBoolean(r["Active"].ToString());
                items.Add(item);
            }
            return items;
        }//End GetAll Types
Example #8
0
 // GET: api/Types/5
 public string Get(string id)
 {
     ptType item = ptsHelper.GetAllTypes().Find(x => x.TypeId == id);
     return JsonConvert.SerializeObject(item);
 }