Example #1
0
        public IHttpActionResult Delete(int id)
        {
            var dao = new News_TypeDAO();

            if (!dao.isExist(id)) // Kiem tra xem id co hop le hay khong
            {
                return(NotFound());
            }
            var check = dao.Delete(id); // Kiem tra viec thuc hien Delete

            return(Ok(check));
        }
Example #2
0
        public IHttpActionResult Put([FromBody] JObject jsonResult)
        {
            if (!ModelState.IsValid)  // Kiem tra tinh hop le cua giu lieu
            {
                return(BadRequest(ModelState));
            }
            var x   = JsonConvert.DeserializeObject <News_TypeDTO>(jsonResult.ToString()); // Ep kieu Json sang DTO
            var dao = new News_TypeDAO();

            if (!dao.isExist(x.ID)) // Kiem tra id co hop le khong
            {
                return(NotFound());
            }
            dao.Update(x); // Cap nhat
            return(Ok());
        }