Ejemplo n.º 1
0
        public IHttpActionResult PostLyDoChi(LyDoChi lyDoChi)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.LyDoChis.Add(lyDoChi);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (LyDoChiExists(lyDoChi.IDLyDoChi))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = lyDoChi.IDLyDoChi }, lyDoChi));
        }
Ejemplo n.º 2
0
        public IHttpActionResult PutLyDoChi(string id, LyDoChi lyDoChi)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != lyDoChi.IDLyDoChi)
            {
                return(BadRequest());
            }

            db.Entry(lyDoChi).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LyDoChiExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        public IHttpActionResult GetLyDoChi(string id)
        {
            LyDoChi lyDoChi = db.LyDoChis.Find(id);

            if (lyDoChi == null)
            {
                return(NotFound());
            }

            return(Ok(lyDoChi));
        }
Ejemplo n.º 4
0
        public LyDoChi LayLyDoChi(long id)
        {
            DataTable tbl  = factory.LayLyDoChi(id);
            LyDoChi   lydo = new LyDoChi();

            if (tbl.Rows.Count > 0)
            {
                lydo.Id   = Convert.ToInt64(tbl.Rows[0]["ID"]);
                lydo.LyDo = Convert.ToString(tbl.Rows[0]["LY_DO"]);
            }
            return(lydo);
        }
Ejemplo n.º 5
0
        public IHttpActionResult DeleteLyDoChi(string id)
        {
            LyDoChi lyDoChi = db.LyDoChis.Find(id);

            if (lyDoChi == null)
            {
                return(NotFound());
            }

            db.LyDoChis.Remove(lyDoChi);
            db.SaveChanges();

            return(Ok(lyDoChi));
        }