예제 #1
0
        public IHttpActionResult PostNV_GIAO_VIEC(NV_GIAO_VIEC nV_GIAO_VIEC)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.NV_GIAO_VIEC.Add(nV_GIAO_VIEC);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = nV_GIAO_VIEC.ID }, nV_GIAO_VIEC));
        }
예제 #2
0
        public IHttpActionResult DeleteNV_GIAO_VIEC(int id)
        {
            NV_GIAO_VIEC nV_GIAO_VIEC = db.NV_GIAO_VIEC.Find(id);

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

            db.NV_GIAO_VIEC.Remove(nV_GIAO_VIEC);
            db.SaveChanges();

            return(Ok(nV_GIAO_VIEC));
        }
예제 #3
0
        public IHttpActionResult PostNV_GIAO_VIEC(NV_GIAO_VIEC giaoviec)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            NV_GIAO_VIEC newviec = new NV_GIAO_VIEC();

            newviec.TIEU_DE_CONG_VIEC    = giaoviec.TIEU_DE_CONG_VIEC;
            newviec.NGAY_GIAO_VIEC       = DateTime.Today.Date;
            newviec.NOI_DUNG_CONG_VIEC   = giaoviec.NOI_DUNG_CONG_VIEC;
            newviec.THOI_GIAN_HOAN_THANH = giaoviec.THOI_GIAN_HOAN_THANH;
            newviec.NGUOI_GIAO_VIEC      = giaoviec.NGUOI_GIAO_VIEC;
            newviec.NHAN_VIEN_THUC_HIEN  = giaoviec.NHAN_VIEN_THUC_HIEN;
            newviec.TRANG_THAI           = giaoviec.TRANG_THAI;
            newviec.GHI_CHU = giaoviec.GHI_CHU;
            db.NV_GIAO_VIEC.Add(newviec);
            db.SaveChanges();

            return(Ok(newviec));
        }
예제 #4
0
        public IHttpActionResult PutNV_GIAO_VIEC(int id, NV_GIAO_VIEC nV_GIAO_VIEC)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var query = db.NV_GIAO_VIEC.Where(x => x.ID == id).FirstOrDefault();

            if (query != null)
            {
                if (nV_GIAO_VIEC.TRANG_THAI == "Đã xong việc")
                {
                    query.THOI_GIAN_HOAN_THANH = Convert.ToString(DateTime.Now);
                }
                query.TRANG_THAI = nV_GIAO_VIEC.TRANG_THAI;
                query.GHI_CHU    = nV_GIAO_VIEC.GHI_CHU;
            }
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NV_GIAO_VIECExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }