Пример #1
0
        public IHttpActionResult Get(int id)
        {
            DTO_PRO_NCVKhac tbl_PRO_NCVKhac = BS_PRO_NCVKhac.get_PRO_NCVKhac(db, id);

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

            return(Ok(tbl_PRO_NCVKhac));
        }
Пример #2
0
        public IHttpActionResult Post(DTO_PRO_NCVKhac tbl_PRO_NCVKhac)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            DTO_PRO_NCVKhac result = BS_PRO_NCVKhac.post_PRO_NCVKhac(db, tbl_PRO_NCVKhac, Username);

            if (result != null)
            {
                return(CreatedAtRoute("get_PRO_NCVKhac", new { id = result.ID }, result));
            }
            return(Conflict());
        }
Пример #3
0
        public static DTO_PRO_NCVKhac post_PRO_NCVKhac(AppEntities db, DTO_PRO_NCVKhac item, string Username)
        {
            tbl_PRO_NCVKhac dbitem = new tbl_PRO_NCVKhac();

            if (item != null)
            {
                dbitem.IDDeTai      = item.IDDeTai;
                dbitem.IDNCV        = item.IDNCV;
                dbitem.ChucDanh     = item.ChucDanh;
                dbitem.ChucVu       = item.ChucVu;
                dbitem.IsCanView    = item.IsCanView;
                dbitem.IsCanChange  = item.IsCanChange;
                dbitem.IsCanApprove = item.IsCanApprove;
                dbitem.IsDisabled   = item.IsDisabled;
                dbitem.IsDeleted    = item.IsDeleted;

                dbitem.CreatedBy   = Username;
                dbitem.CreatedDate = DateTime.Now;

                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;


                try
                {
                    db.tbl_PRO_NCVKhac.Add(dbitem);
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, null, "DTO_PRO_NCVKhac", DateTime.Now, Username);


                    item.ID = dbitem.ID;

                    item.CreatedBy   = dbitem.CreatedBy;
                    item.CreatedDate = dbitem.CreatedDate;

                    item.ModifiedBy   = dbitem.ModifiedBy;
                    item.ModifiedDate = dbitem.ModifiedDate;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("post_PRO_NCVKhac", e);
                    item = null;
                }
            }
            return(item);
        }
Пример #4
0
        public IHttpActionResult Put(int id, DTO_PRO_NCVKhac tbl_PRO_NCVKhac)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tbl_PRO_NCVKhac.ID)
            {
                return(BadRequest());
            }

            bool result = BS_PRO_NCVKhac.put_PRO_NCVKhac(db, id, tbl_PRO_NCVKhac, Username);

            if (result)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                return(NotFound());
            }
        }
Пример #5
0
        public static bool put_PRO_NCVKhac(AppEntities db, int ID, DTO_PRO_NCVKhac item, string Username)
        {
            bool result = false;
            var  dbitem = db.tbl_PRO_NCVKhac.Find(ID);

            if (dbitem != null)
            {
                dbitem.IDDeTai      = item.IDDeTai;
                dbitem.IDNCV        = item.IDNCV;
                dbitem.ChucDanh     = item.ChucDanh;
                dbitem.ChucVu       = item.ChucVu;
                dbitem.IsCanView    = item.IsCanView;
                dbitem.IsCanChange  = item.IsCanChange;
                dbitem.IsCanApprove = item.IsCanApprove;
                dbitem.IsDisabled   = item.IsDisabled;
                dbitem.IsDeleted    = item.IsDeleted;

                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;

                try
                {
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, null, "DTO_PRO_NCVKhac", DateTime.Now, Username);

                    result = true;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("put_PRO_NCVKhac", e);
                    result = false;
                }
            }
            return(result);
        }