Ejemplo n.º 1
0
        // DELETE api/<controller>/5
        public void Delete(int id)
        {
            KenhTinBaiViet obj = db.KenhTinBaiViets.Where(o => o.Id == id).SingleOrDefault();

            db.KenhTinBaiViets.DeleteOnSubmit(obj);
            db.SubmitChanges();
        }
Ejemplo n.º 2
0
        // PUT api/<controller>/5
        public void Put(int id, [FromBody] KenhTinBaiViet value)
        {
            KenhTinBaiViet obj    = db.KenhTinBaiViets.Where(o => o.Id == id).SingleOrDefault();
            KenhTinBaiViet newobj = value;// JsonConvert.DeserializeObject<KenhTinBaiViet>(value);

            if (newobj.NoiDung != null)
            {
                obj.NoiDung = newobj.NoiDung;
            }
            if (newobj.MaCapTren != null)
            {
                obj.MaCapTren = newobj.MaCapTren;
            }
            db.SubmitChanges();
        }
Ejemplo n.º 3
0
        public IEnumerable <KenhTinBaiViet> Get()
        {
            string filter = HttpContext.Current.Request.Params.Get("filter");

            if (string.IsNullOrEmpty(filter))
            {
                List <KenhTinBaiViet> lst = (from table in db.KenhTinBaiViets
                                             select table).ToList();
                return(lst);
                //string json = JsonConvert.SerializeObject(lst);
                //return new string[] { json };
            }
            else
            {
                KenhTinBaiViet        obj = JsonConvert.DeserializeObject <KenhTinBaiViet>(filter);
                List <KenhTinBaiViet> lst = (from table in db.KenhTinBaiViets
                                             where
                                             (obj.MaCapTren == null || obj.MaCapTren == table.MaCapTren)
                                             select table).ToList();
                return(lst);
                //string json = JsonConvert.SerializeObject(lst);
                //return new string[] { json };
            }
        }
Ejemplo n.º 4
0
 // POST api/<controller>
 public void Post([FromBody] KenhTinBaiViet value)
 {
     // KenhTinBaiViet newobj = (KenhTinBaiViet)JsonConvert.DeserializeObject(value);
     db.KenhTinBaiViets.InsertOnSubmit(value);
     db.SubmitChanges();
 }