Пример #1
0
        public static bool put_PRO_HoiNghiHoiThaoCustom(AppEntities db, int ID, DTO_PRO_HoiNghiHoiThao item, string Username)
        {
            bool result = false;
            var  dbitem = db.tbl_PRO_HoiNghiHoiThao.Find(ID);

            if (dbitem != null)
            {
                dbitem.ThoiGian       = item.ThoiGian;
                dbitem.ThoiGianHetHan = item.ThoiGianHetHan;
                dbitem.DiaDiem        = item.DiaDiem;
                dbitem.TenHoiNghi     = item.TenHoiNghi;
                dbitem.IDSite         = item.IDSite;
                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_HoiNghiHoiThao", DateTime.Now, Username);

                    result = true;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("put_PRO_HoiNghiHoiThaoCustom", e);
                    result = false;
                }
            }
            return(result);
        }
        public IHttpActionResult UploadFullText(DTO_PRO_HoiNghiHoiThao item)
        {
            BS_PRO_HoiNghiHoiThao.uploadFullText_PRO_HoiNghiHoiThao(db, item.ID, item.BaiFulltext, Username);
            var res = BS_PRO_HoiNghiHoiThao.get_PRO_HoiNghiHoiThao(db, item.ID);

            if (res == null)
            {
                return(NotFound());
            }
            return(Ok(res));
        }
        public IHttpActionResult Get(int id)
        {
            DTO_PRO_HoiNghiHoiThao tbl_PRO_HoiNghiHoiThao = BS_PRO_HoiNghiHoiThao.get_PRO_HoiNghiHoiThao(db, id);

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

            return(Ok(tbl_PRO_HoiNghiHoiThao));
        }
        public static DTO_PRO_HoiNghiHoiThao post_PRO_HoiNghiHoiThao(AppEntities db, DTO_PRO_HoiNghiHoiThao item, string Username)
        {
            tbl_PRO_HoiNghiHoiThao dbitem = new tbl_PRO_HoiNghiHoiThao();

            if (item != null)
            {
                dbitem.IDNhanVien     = item.IDNhanVien;
                dbitem.ThoiGian       = item.ThoiGian;
                dbitem.DiaDiem        = item.DiaDiem;
                dbitem.TenHoiNghi     = item.TenHoiNghi;
                dbitem.CVBaoCaoVien   = item.CVBaoCaoVien;
                dbitem.BaiAbstract    = item.BaiAbstract;
                dbitem.BaiFulltext    = item.BaiFulltext;
                dbitem.HTMLHosrem     = item.HTMLHosrem;
                dbitem.IDTrangThai    = item.IDTrangThai;
                dbitem.IsDisabled     = item.IsDisabled;
                dbitem.IsDeleted      = item.IsDeleted;
                dbitem.ThoiGianHetHan = item.ThoiGianHetHan;
                dbitem.IDSite         = item.IDSite;

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

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


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

                    BS_CUS_Version.update_CUS_Version(db, null, "DTO_PRO_HoiNghiHoiThao", 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_HoiNghiHoiThao", e);
                    item = null;
                }
            }
            return(item);
        }
        public IHttpActionResult Post(DTO_PRO_HoiNghiHoiThao tbl_PRO_HoiNghiHoiThao)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            tbl_PRO_HoiNghiHoiThao.IDTrangThai = -(int)SYSVarType.TrangThai_HNHT_ChoGui;
            DTO_PRO_HoiNghiHoiThao result = BS_PRO_HoiNghiHoiThao.post_PRO_HoiNghiHoiThaoCustom(db, tbl_PRO_HoiNghiHoiThao, Username);

            if (result != null)
            {
                return(CreatedAtRoute("get_PRO_HoiNghiHoiThao", new { id = result.ID }, result));
            }
            return(Conflict());
        }
        public IHttpActionResult UpdateStatus(int id, string actionCode)
        {
            var result = BS_PRO_HoiNghiHoiThao.updateStatus_PRO_HoiNghiHoiThao(db, id, actionCode, Username);

            if (!string.IsNullOrEmpty(result))
            {
                return(BadRequest(result));
            }
            DTO_PRO_HoiNghiHoiThao tbl_PRO_HoiNghiHoiThao = BS_PRO_HoiNghiHoiThao.get_PRO_HoiNghiHoiThao(db, id);

            if (tbl_PRO_HoiNghiHoiThao == null)
            {
                return(NotFound());
            }
            return(Ok(tbl_PRO_HoiNghiHoiThao));
        }
        public IHttpActionResult Put(int id, DTO_PRO_HoiNghiHoiThao tbl_PRO_HoiNghiHoiThao)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            bool res = BS_PRO_HoiNghiHoiThao.put_PRO_HoiNghiHoiThaoCustom(db, id, tbl_PRO_HoiNghiHoiThao, Username);

            if (res)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                return(NotFound());
            }
        }