public static bool put_WEB_BaiViet_DanhMuc(AppEntities db, int ID, DTO_WEB_BaiViet_DanhMuc item, string Username) { bool result = false; var dbitem = db.tbl_WEB_BaiViet_DanhMuc.Find(ID); if (dbitem != null) { dbitem.IDDanhMuc = item.IDDanhMuc; dbitem.IDBaiViet = item.IDBaiViet; dbitem.URL = item.URL; 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_DanhMuc", dbitem.ModifiedDate, Username); result = true; } catch (DbEntityValidationException e) { errorLog.logMessage("put_WEB_BaiViet_DanhMuc", e); result = false; } } return(result); }
public static DTO_WEB_BaiViet_DanhMuc post_WEB_BaiViet_DanhMuc(AppEntities db, DTO_WEB_BaiViet_DanhMuc item, string Username) { tbl_WEB_BaiViet_DanhMuc dbitem = new tbl_WEB_BaiViet_DanhMuc(); if (item != null) { dbitem.IDDanhMuc = item.IDDanhMuc; dbitem.IDBaiViet = item.IDBaiViet; dbitem.URL = item.URL; 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_DanhMuc.Add(dbitem); db.SaveChanges(); BS_CUS_Version.update_CUS_Version(db, null, "DTO_WEB_BaiViet_DanhMuc", 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_DanhMuc", e); item = null; } } return(item); }