Example #1
0
        public IHttpActionResult Get(int id)
        {
            var b = new Bill_DetailsDAO().Take(id); // Lay phan tu voi id tuong ung

            if (b == null)
            {
                return(NotFound());
            }
            return(Ok(b));
        }
Example #2
0
        public IHttpActionResult Post([FromUri] JObject jsonResult)
        {
            if (!ModelState.IsValid)  // Kiem tra tinh hop le cua giu lieu
            {
                return(BadRequest(ModelState));
            }
            var x    = JsonConvert.DeserializeObject <Bill_DetailsDTO>(jsonResult.ToString());
            var last = new Bill_DetailsDAO().Add(x);

            return(Ok(last));
        }
Example #3
0
        public IHttpActionResult Delete(int idProduct, int idBill)
        {
            var dao = new Bill_DetailsDAO();

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

            return(Ok(check));
        }
Example #4
0
        public IHttpActionResult GetAllUsers(int?number)
        {
            IEnumerable <Bill_DetailsDTO> ls;

            if (number == null)
            {
                ls = new Bill_DetailsDAO().List();
            }
            else
            {
                ls = new Bill_DetailsDAO().List().Take((int)number);
            }
            if (ls == null)
            {
                return(NotFound());
            }
            return(Ok(ls));
        }