Beispiel #1
0
        public static bool put_WEB_BaiViet_Tag(AppEntities db, int ID, DTO_WEB_BaiViet_Tag item, string Username)
        {
            bool result = false;
            var  dbitem = db.tbl_WEB_BaiViet_Tag.Find(ID);

            if (dbitem != null)
            {
                dbitem.IDBaiViet  = item.IDBaiViet;
                dbitem.IDTag      = item.IDTag;
                dbitem.Sort       = item.Sort;
                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_WEB_BaiViet_Tag", dbitem.ModifiedDate, Username);

                    result = true;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("put_WEB_BaiViet_Tag", e);
                    result = false;
                }
            }
            return(result);
        }
Beispiel #2
0
        public static DTO_WEB_BaiViet_Tag post_WEB_BaiViet_Tag(AppEntities db, DTO_WEB_BaiViet_Tag item, string Username)
        {
            tbl_WEB_BaiViet_Tag dbitem = new tbl_WEB_BaiViet_Tag();

            if (item != null)
            {
                dbitem.IDBaiViet  = item.IDBaiViet;
                dbitem.IDTag      = item.IDTag;
                dbitem.Sort       = item.Sort;
                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_WEB_BaiViet_Tag.Add(dbitem);
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, null, "DTO_WEB_BaiViet_Tag", dbitem.ModifiedDate, 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_WEB_BaiViet_Tag", e);
                    item = null;
                }
            }
            return(item);
        }